Proxying JAX-WS (Fast-Infoset) Messages

Sample Number

202

Level

Introductory

Description

This sample demonstrates the usage of UltraESB to proxy Fast-Infoset messages to a non Fast-Infoset back-end

Use Case

I have a XML service (typical web service) and I want to mediate the invocation of this service with the ESB, such that the service is available to be accessed as a JAX-WS service over Fast-Infoset. Request messages going into the service via ESB needs to be converted from Fast-Infoset into (possibly) XML and any response going through ESB from this service needs to be converted back to Fast-Infoset.

sample 202

As shown in the above diagram, instead of directly talking to the XML service, UltraESB acts as the proxy for all the requests going to the back-end server in-order to mediate the messages providing a JAX-WS interface with Fast-Infoset support to the service.

Sample Configuration

The configuration for this use case is straight forward which consists of a proxy service, exposed on the HTTP/S transports and forwards the incoming message into the target back-end service configured using the in destination of the proxy service, after mediating with the specified in sequence. The in sequence uses the mediation API to convert the Fast-Infoset messages into XML.

Proxy service configuration for the restful proxy service

 1<u:proxy id="jax-ws-proxy">
 2  <u:transport id="http-8280"/>
 3  <u:target>
 4    <u:inSequence>
 5      <u:java><![CDATA[
 6        mediation.getXMLSupport().convertFromFI(msg);
 7        msg.setContentType("text/xml");
 8        msg.removeTransportHeader("Accept");
 9      ]]></u:java>
10    </u:inSequence>
11    <u:inDestination>
12      <u:address>http ://localhost:9000/service/SimpleStockQuoteService</u:address>
13    </u:inDestination>
14    <u:outSequence>
15      <u:java><![CDATA[
16        mediation.getXMLSupport().convertToFI(msg);
17        msg.setContentType("application/fastinfoset");
18      ]]></u:java>
19    </u:outSequence>
20    <u:outDestination>
21      <u:address type="response"/>
22    </u:outDestination>
23  </u:target>
24</u:proxy>

The configuration also specifies the response from the back-end service to be delivered back to the caller, using a response type endpoint. In the out path before delivering the response back to the client, the defined out sequence uses the mediation API to convert the XML responses from the back-end service back into the Fast-Infoset format.

Note that, in the in sequence the "Accept" HTTP transport header has been removed so that the back end service does not response with a Fast-Infoset message, to demonstrate the out path conversion.

Note
For the simplicity the complete configuration is not displayed here, you may look at the complete configuration either from the binary distribution under samples/conf/ultra-sample-202.xml, or from the sample 202 configuration of the source tag.

In Action

To run the example, start the UltraESB sample configuration 202 via the ToolBox or on the command line as follows.

Running the sample from startup script

$ cd /opt/ultraesb-2.6.1/bin
$ ./ultraesb.sh -sample 202

Now start the SOA Toolbox, and fire-up the sample Jetty server on port 9000 that holds a SimpleStockQuoteService sample service for testing.

The proxy service endpoint will be http://localhost:8280/service/jax-ws-proxy, while the original SimpleStockQuoteService sample hosted on the Jetty server is available at http://localhost:9000/service/SimpleStockQuoteService. Use the SOA Toolbox and send a Preset "1" request message to the "jax-ws-proxy" service hosted on the UltraESB to test the sample.

Related Samples

Sample Number

Sample Title

201

Proxying SOAP Messages

101

Restful Proxy Services

In this topic
In this topic
Contact Us