Chapter 8. Router solutions using Web Services Gateway 183
Figure 8-21 shows the results of the Enterprise Bean wizard.
Figure 8-21 Developing a filter with WebSphere Studio
A filter can get the list of potential target services from the Web Services
Gateway Routing service. The Home object for this service must implement the
com.ibm.wsgw.beans.RoutingHome interface and be located in JNDI at
websphere/WSGW/Routing.
The sequence of events is as follows:
1. The filter is called with a WSIFRequest.
2. The filter obtains the list of potential target services from the Routing service.
3. The filter selects the target service.
4. The filter calls the Routing service to set the target service (note that doing
this clears any prior selection of a target service's port).
Each target service is identified by its unique target service definition location
and target service identity information (which might not be unique). To select the
target service, your filter can either get the table of mappings from the target
service location to identity information, then choose a target service to use; or it
can call setSelectedTargetServiceIdentity with the required identity string (relying
on the target service identity information being carefully defined).
184 Broker Interactions for Intra- and Inter-enterprise
The routing service then selects the first target service it finds (for the current
gateway service) with identity information matching that specified (using
String.equals()).
The filter can also use the Routing service to select the target port for the service
invocation.
Example 8-5 shows how to determine the target service using a filter.
Example 8-5 RouterBean.java
public FilterAction filterRequest(WSIFRequest req, WSIFResponse resp)
throws FilterException, WSGWException {
try {
InitialContext initialContext = new InitialContext();
RoutingHome routingHome =
(RoutingHome)PortableRemoteObject.narrow(
initialContext.lookup("websphere/WSGW/Routing"), RoutingHome.class);
RoutingRemote routing = routingHome.create();
WSIFMessage message = req.getIncomingMessage();
String partNumber = ((JROMStringValue)message.getObjectPart("partNo")).getValue();
if (Integer.parseInt(partNumber)<100) {
routing.setSelectedTargetServiceIdentity(req, "InventoryServiceWholesale1");
} else {
routing.setSelectedTargetServiceIdentity(req, "InventoryServiceWholesale2");
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return null;
}
Note that the target services identified here haven’t been defined to the Web
Services Gateway yet. Later, when you define them, the target service identity
information (see Figure 8-26 on page 190) must match with the filter code.
Note: When you use Routing to set the target service or the target port, the
Routing service updates the request context. Because the request context has
changed, you then need to set the request object in the FilterAction object that
you return from the filterRequest method.
Chapter 8. Router solutions using Web Services Gateway 185
Deploy the filter
To deploy the filter, you have to install the enterprise application that contains the
filter. Later, you will also need to configure the filter to the Web Services
Gateway. Follow these steps:
1. Export the EAR file from WebSphere Studio to the
<was_install>/installableapps directory.
1. Using the WebSphere administrative console for server1 (where the Web
Services Gateway application is installed), select Applications->Install New
Application.
2. Browse to the ear file (ITSORouterApp for our scenario), select it and click
Next.
3. As you proceed through the application installation, the steps may vary
depending on the features of the application (whether it uses security, a
database, etc.). As you go through the install, make sure the JNDI name for
the EJB is correct.
Refer to Figure 8-22.
Figure 8-22 Installing the filter application - panel 3
4. Complete the installation and start the application.
186 Broker Interactions for Intra- and Inter-enterprise
8.6.5 Define the services and filter to Web Services Gateway
Before you define a Web service to the Web Services Gateway, deploy the
resources (channels, filters, UDDI references and security bindings) that the
Web service uses.
1. Install the Web Services Gateway. The Web Services Gateway used in this
scenario was installed from and deployed on WebSphere Application Server
Enterprise V5.0.2 with the 5021 fix applied.
Once the application server and the Web services features have been
installed and brought up to the correct fixpack level, you will need to complete
the installation of the Web Services Gateway using the instructions in the
InfoCenter.
The Web Services Gateway is an enterprise application that runs on an
application server, so this process includes creating a database for the Web
Services Gateway to store data in, and installing the Web Services Gateway
applications. Scripts are provided to do this.
2. Perform the initial configuration of the gateway, including the namespace URI.
If you change the namespace URI, you break the link back to the Web
Services Gateway for every Web service that you have already deployed. So
you must set the namespace URI before you deploy any Web services.
3. Add a channel to handle incoming SOAP requests.
4. Add a reference to the UDDI Registry.
5. Deploy the Web services to the gateway. If you aren’t using a filter to route
service requests, you will need to create one service for each service provider
(InventoryWholesale1 and InventoryWholesale2). If you are using a filter to
route requests, you will only need to create one service, with two target
services (InventoryWholesale1 and InventoryWholesale2).
Initial configuration
1. Open the Web Services Gateway administration console at:
http://wsgw_host:9080/wsgw/admin/
2. Select the Configure option under Gateway.
3. Enter the following values (Figure 8-23):
Namespace URI for services: urn:ibmwsgw. (default)
WSDL URI for exported definitions: http://wsgw_host:port/wsgw
Chapter 8. Router solutions using Web Services Gateway 187
Figure 8-23 Initial gateway configuration
4. Click Apply Changes.
Add a channel
To deploy a channel for incoming SOAP requests (Figure 8-24):
1. Select Deploy under the Channels menu option.
2. Enter the following values:
Channel Name: SOAPHTTPChannel1
Home Location: SOAPHTTPChannel1Bean
End Point Address: http://wsgw:9080/wsgwsoaphttp1
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.0.85