In the sample the operation is extracted from the SOAP request message and a user defined configurable service is used to retrieve the URL of the web service provider.
The sample wizard overrides the URL on the SOAPRequest nodes in the consumer flow bar files. If you choose to rebuild the bar files these settings might be cleared and the gateway flow not invoked.
The Web Services Gateway sample demonstrates the following tasks:
Before you start, you must be familiar with the existing samples that this sample builds upon.
The following diagram shows the Web Services Gateway message flow:
The following table shows the nodes in the message flow:
Node type | Node name |
---|---|
SOAPInput | GatewayInput |
JavaCompute | ComputeURL |
SOAPRequest | SOAP Request |
SOAPReply | GatewayReply |
The SOAPInput node operates in gateway mode and accepts requests from either the Address Book sample or SOAP Node sample consumer flows.
The JavaCompute node gets the operation name from the incoming request message and stores this in csName. The sample setup wizard creates a User Defined configurable service called Gateway, and a property matching the operation names for two consumer flows from the existing samples. The BrokerProxy is used to get the value of the configurable service and set the URL for the request in the local environment.
List nodeset = (List)message.getRootElement().evaluateXPath("SOAP/Body/*[1]"); String csName=((MbElement)(nodeset.get(0))).getName(); String URL = null; try { //Get the broker proxy BrokerProxy bp = BrokerProxy.getLocalInstance(); //Find the URL from a configurable service URL = bp.getConfigurableServiceProperty("UserDefined/Gateway/"+csName); } catch (Exception e) { URL="/"; } //Set the WebServiceURL creating the path if it doesn't exist le.getRootElement().evaluateXPath("?Destination/?SOAP/?Request/?Transport/?HTTP/?WebServiceURL[set-value('"+URL+"')]");
The SOAPRequest node sends the request to the appropriate provider flow.
The SOAPReply node returns the response to the calling consumer flow.
The SOAP messages are generated by the existing consumer and provider flows. The gateway flow uses the operation name to route it to the correct provider.
After running the sample you might want to extend it by adding another web service provider. Because a configurable service is used to store the URL for the provider, all you need to do is add a property with the name of an existing service operation, and the value set to the URL.