Installing the RPC adapter libraries
The RPC adapter for IBM® WebSphere® Application Server Feature Pack for Web 2.0 is provided as either stand-alone, or as an Eclipse
plug-in. For WebSphere Application Server Community Edition,
only the standalone package is available. Let us assume that <install_root> is the directory where the feature pack is installed,
which is the case for WebSphere Application Server, for example, and <WASCEFEP_HOME> is the directory
where the WebSphere Application Server Community Edition feature pack is unzipped. You can use either
the stand-alone library or the Eclipse plug-in. The steps for both methods are provided.
1) Standalone Library:
The IBM RPC adapter is provided as a stand-alone library in the <install_root>/web2fep/optionalLibraries/RPCAdapter
directory in the case you installed the feature pack for WebSphere Application Server v6.0.2.x, v6.1.x or v7.0.0.x.
In the case of WebSphere Application Server Community Edition the libraries can be located at
<WASCEFEP_HOME>/RPCAdapter/lib. You can add the RPCAdapter.jar file to the WEB-INF/lib directory of
your Web application and use it for exposing POJO methods as services. You will also need to add the
commons-logging-1.0.4.jar and the retroweaver-rt-2.0.jar files from that directory to the
WEB-INF/lib directory. Another file that you will need to add to the WEB-INF/lib directory of your Web
application is the JSON4J.jar file from <install_root>/web2fep/optionalLibraries/JSON4J. Note that you also
need to create and add a RpcAdapterConfig.xml file in the WEB-INF directory.
The standalone library can be used with
Web applications or Enterprise Applications that need to invoke methods of JavaTM objects from JavaScriptTM. Installation of this library is
dependent on how the application that uses it is packaged and
implemented. A few general scenarios are provided.
Java Platform, Enterprise Edition (Java EE) Web application:
- Place the rpcAdapter.jar file in the WEB-INF/lib directory of the Web application containing the Java objects that
you want to make accessible. You should also add the JSON4J.jar and retroweaver-rt-2.0.jar libraries to the
lib directory of your Web application as they are required by the RPC adapter library at run time.
- Configure the web.xml file so that the servlet com.ibm.websphere.rpcadapter.RPCAdapter is exposed under
the Web address: http://<host>:<port>/<contextRoot>/RPCAdapter/*. Add the following servlet configuration
to your web.xml file:
RPCAdapter
RPCAdapter
com.ibm.websphere.rpcadapter.RPCAdapter
RPCAdapter
/RPCAdapter
RPCAdapter
/RPCAdapter/*
This is for routing all calls to the application with RPC adapter in the URL to the com.ibm.websphere.rpcadapter.RPCAdapter servlet.
- Create a RpcAdapterConfig.xml and place it in the WEB-INF folder.
Specify the POJO that are exposed through RPC adapter in the configuration file. An example of a basic configuration
that exposes a TestService follows:
xml
TestService
com.ibm.test.TestService
bean provides ...
- Start the application server.
- Package and deploy the Web application. Refer to the application server specific documentation on
instructions for packaging and deploying a Web archive (WAR) or Enterprise archive (EAR) file.
- Use the following directory of URLs to interact with the RPC adapter for information and RPC:
- GET <baseUrl>/httprpc -- directory of registered services
- GET <baseUrl>/httprpc/<serviceName> -- list of operations on <serviceName>
- GET <baseUrl>/httprpc/<serviceName>/<operation>[?name=value] -- HTTP RPC invocation
- POST <baseUrl>/httprpc/<serviceName>/<operation> [BODY: name=value] -- HTTP RPC invocation
- GET <baseUrl>/jsonrpc/<serviceName> -- Dojo SMD file
- POST <baseUrl>/jsonrpc/<serviceName> [BODY: JSON-RPC request] -- JSON RPC invocation
- Use Dojo to invoke the services exposed through RPC adapter using the dojo.rpc.JsonService script. Refer to the Dojo documentation on detailed usage information.
2) Eclipse projects:
If you want to import the RPC adapter library into a Web project in eclipse, install the Eclipse library plug-in.
Use the following steps to import the RPCAdapter library into a Web project in eclipse:
- Start Eclipse. The plug-in requires Eclipse 3.2.x with WTP 1.5.x.
- Select Help > Software Updates > Find and Install.
- Select Search for new features to install.
- On the Install panel, select the New Archived Site.
- Enter the location of the IBM WebSphere Application Server Feature Pack for Web 2.0 Eclipse archive zip file. The zip file will be present in the <install_root>/web2fep/site directory.
- Complete the plug-in installation. You are prompted to restart Eclipse when you finish.
- Select your project in the Package Explorer and expand it.
- Expand Web Content and right click on the lib directory in WEB-INF. This brings up the Context Menu.
- Select Import > General > File System, and click Next.
- Browse to the plug-ins directory of your Eclipse installation and to the
com.ibm.websphere.rpcadapter_1.0.0.1/lib directory and select the RPCAdapter.jar,
commons-logging-1.0.4.jar and retroweaver-rt-2.0.jar files and click Finish.
- This imports the RPCAdapter.jar, commons-logging-1.0.4.jar and the retroweaver-rt-2.0.jar files into the lib directory.
- Similarly import the JSON4J.jar file from <ECLIPSE_HOME>/plugins/com.ibm.json_1.0.0.1/lib into the WEB-INF/lib directory of your Web application where <ECLIPSE_HOME> is the directory of your eclipse installation.
- Configure the web.xml file so that the servlet com.ibm.websphere.rpcadapter.RPCAdapter is exposed under the URL http://<host>:<port>/<contextRoot>/RPCAdapter/*. The following servlet configuration needs to be added to your Web.xml file for this.
RPCAdapter
RPCAdapter
com.ibm.websphere.rpcadapter.RPCAdapter
RPCAdapter
/RPCAdapter
RPCAdapter
/RPCAdapter/*
This code routes all calls to the application with RPC adapter in the URL to the com.ibm.websphere.rpcadapter.RPCAdapter servlet.
- Create a RpcAdapterConfig.xml and place it in the WEB-INF folder.
Specify the POJO that needs to exposed through RPC adapter in the configuration file. A basic configuration exposing a TestService is given below:
xml
TestService
com.ibm.test.TestService
bean provides ...
- If you have an embedded server run time, follow the steps required to start it and deploy your Web application.
- Interact with the RPC adapter for information and RPC using the following directory of URLs:
- GET <baseUrl>/httprpc -- directory of registered services
- GET <baseUrl>/httprpc/<serviceName> -- list of operations on <serviceName>
- GET <baseUrl>/httprpc/<serviceName>/<operation>[?name=value] -- HTTP RPC invocation
- POST <baseUrl>/httprpc/<serviceName>/<operation> [BODY: name=value] -- HTTP RPC invocation
- GET <baseUrl>/jsonrpc/<serviceName> -- Dojo SMD file
- POST <baseUrl>/jsonrpc/<serviceName> [BODY: JSON-RPC request] -- JSON RPC invocation
- You can use Dojo to invoke the services exposed through RPC adapter. You can use the dojo.rpc.JsonService script. Refer to the Dojo documentation on detailed usage information.