Home

 

Exposing an RPC Adapter service

In this step we create the RPC Adapter service that returns a JSON response. We require a service that returns the customer information by SSN.

To expose a service, do these steps:

In the Web perspective, select Window Æ Show View Æ Other Æ General Æ Services.

In the Services view, right-click RPC Adapter and select Expose RPC Adapter Service (Figure | 9-8).

Figure 19-8 Exposing an RPC Adapter Service

In the Expose RPC Adapter Service dialog (Figure | 9-9), enter the following data:

Web Project: RAD75Web20Dojo
Class: itso.bank.entity.controller.CustomerManager
Service Name: CustomerService
Methods: Select findCustomerBySsn.
Click Next.

Figure 19-9 Exposing a service

In the Configure Methods dialog (Figure | 9-10), accept the default options and click Finish.

Figure 19-10 Configure Methods

The service has been exposed. The RPC adapter is created in the Services view and the findCustomerBySsn method is exposed (Figure | 9-11).

Figure 19-11 RPC Adapter with an exposed service

When we create an RPC Adapter service, we are adding an abstract layer,
no matter which technology is used on the server to obtain the information requested. The client side only needs to know the address (URL) and the format of the data returned. Services provide encapsulation, reuse, and loose-coupling.

The service is stored in the WebContent/WEB-INF/RpcAdapterConfig.xml file (Example | 9-4).

Example 19-4 RpcAdapterConfig.xml file (formatted)

<rpcAdapter ......>
	<default-format>json</default-format>
	<converters></converters>
	<validators>
		<validator id="default">
			<validation-regex>([A-Za-z])+</validation-regex>
			<validation-class>com.ibm.websphere.rpcadapter.DefaultValidator
			</validation-class>
		</validator>
	</validators>
	<services>		
		<pojo>
			<name>CustomerService</name>
			<implementation>itso.bank.entity.controller.CustomerManager</...>
			<methods filter="whitelisting">
				<method>
					<name>findCustomerBySsn</name>
					<alias>findCustomerBySsn</alias>
					<description>Invokes findCustomerBySsn(String)</description>
					<http-method>GET</http-method>
					<parameters>
						<parameter>
							<name>ssn</name>
							<type>java.lang.String</type>
							<description></description>
						</parameter>
					</parameters>
				</method>
			</methods>
		</pojo>
	</services>
	<serialized-params></serialized-params>
</rpcAdapter>

ibm.com/redbooks