Proxying SOAP Messages

Sample Number





This sample demonstrates the usage of UltraESB to proxy SOAP web services

Use Case

I have a web service and I want to mediate the invocation of this web service with the ESB. Web services use SOAP as there application level protocol and my proxy service should expose itself as a SOAP aware proxy service which also acts as a web service, where clients see it as the actual public API of my service.

soap proxy

As shown in the above diagram, instead of directly talking to the back-end web service, UltraESB acts as the proxy for all the requests going to the back-end server and provides the external API (WSDL) to the users.

Sample Configuration

First of all this use case requires the transport to be able to present WSDL and XSDs of the proxy service, on the same service URL with the additional ?wsdl and ?xsd query parameters. Therefore, the HTTP transport listener is decorated with the ServiceResourceRequestFilter, that will detect ?wsdl and ?xsd suffixes in requests, and serve the requested resource without passing the request into the proxy service for mediation. The transport listener is configured as shown below to enable the request filter.

HTTP transport configuration with the filters to process ?wsdl and ?xsd requests

 1<bean id="http-8280" class="org.adroitlogic.ultraesb.transport.http.HttpNIOListener">
 2  <constructor-arg ref="fileCache"/>
 3  <property name="port" value="8280"/>
 4  <property name="requestFilters">
 5    <list>
 6      <bean class="org.adroitlogic.ultraesb.transport.http.ServiceResourceRequestFilter">
 7        <property name="resourcePrefix" value="http://localhost:8280"/>
 8      </bean>
 9    </list>
10  </property>

The property ’resourcePrefix’ defined against the ServiceResourceRequestFilter gives the URL prefix for the service location shown in the WSDL and also the externally visible URL for the resources such as the WSDL and XSDs. This allows one to define the externally visible hostname/domain etc.

The Proxy service itself is a simple definition as shown below. It defines the base URL for the service WSDL - which can be specified as a local file, or by pointing to the WSDL from a real back-end service.

SOAP proxy service configuration

 1<u:proxy id="soap-proxy">
 2  <u:transport id="http-8280">
 3    <!--<u:property name="ultra.http.wsdl_url" value="file:resources/samples/resources/SimpleStockQuoteService.wsdl"/>-->
 4    <u:property name="ultra.http.wsdl_url" value="http://localhost:9000/service/SimpleStockQuoteService?wsdl"/>
 5  </u:transport>
 6  <u:target>
 7    <u:inDestination>
 8      <u:address>http://localhost:9000/service/SimpleStockQuoteService</u:address>
 9    </u:inDestination>
10    <u:outDestination>
11      <u:address type="response"/>
12    </u:outDestination>
13  </u:target>

This configuration is pretty straight forward where it forwards the requests coming in, into the in destination specified to be the sample back-end service, and deliver the response back to the client.

Resource can be located from the local file system too
Note the 3rd line of the displayed configuration which displays how you can point to a WSDL resource in the local file system as the service WSDL

Note that the actual configuration contains few other beans like file cache, transport sender and so forth which are not displayed for the simplicity, you may find the complete configuration either on the samples/conf/ultra-sample-201.xml file in the UltraESB distribution or on the source tag sample configuration file.

In Action

To try out this sample, start the sample configuration 201 of the UltraESB through the ToolBox, or the command line as follows;

Running the sample from startup script

$ cd /opt/ultraesb-2.6.1/bin
$ ./ -sample 201

Now start the sample Jetty server through the ToolBox, and then pointing your browser to http://localhost:8280/service/soap-proxy?wsdl will show you the re-written WSDL for the proxy service, based on the original WSDL supplied. Note that as the UltraESB does not validate, parse or change the WSDL - you can make the UltraESB show any WSDL you wish - exactly as you want! It will only point the service location to the proxy service, and update the schema references to be correct and available through the proxy service itself as shown below. In the example below, the 'resourcePrefix' was set to "http://asankha:8280" and thus appears appropriately as expected.

proxy wsdl

To test the proxy service with a SOAP request, start the HTTP/S client of the SOA Toolbox, and issue a Preset "1" request payload against the Proxy service URL http://localhost:8280/service/soap-proxy.

You may also be interested to look at the Original WSDL at URL http://localhost:9000/service/SimpleStockQuoteService?wsdl and see the modifications done by the proxy when displaying it to the end clients.

Related Samples

Sample Number



Restful Proxy Services

In this topic
In this topic
Contact Us