In this post I show you how I setup a little test to see if and how easy I could manage to route the traffic to and from a web service through Mule ESB. The business case for this is an issue that one of our customers ran into when using web services. In a program hundreds of calls are done in a relative short period. Most of the time this isn’t a problem but sometimes vague issues occur. To get a better insight in this issue I want to put Mule in the middle so I can log the request and response and hopefully get a better idea about what is sent across the line. This is called the Web Service Proxy pattern and is commonly used to validate and audit the web service calls. For more background info about this pattern see this article.
To get started I downloaded the Mule Standalone edition here and installed it. That isn’t very hard, just untar the thing and set the MULE_HOME property. Go to the bin directory and give ‘./mule’ and off you go (except for a warning when running on MacOS 64-bit, but it doesn’t seem to harm so far…):

To create a test web service I setup a MockService in SoapUI. Like this:

All you need is a WSDL available. I just picked one from a previous project for testing purposes. With this MockService started you can fire your SOAP requests and will receive a (predefined) response from the MockService:

Next step is create a new Mule project (I still favor Maven above the Mule Studio):
- create new Maven project with
- Set up the WS Proxy
- Fire up the proxy
mvn mule-project-archetype:create -DartifactId=WSProxy -DmuleVersion=3.1.2
To create WS Proxy I followed the description here
Note: to make use of the pre-defined ‘pattern’ you must add the following dependency to the pom:
1 2 3 4 5 6 | <dependency> <groupId>org.mule.patterns</groupId> <artifactId>mule-patterns-all</artifactId> <version>${mule.version}</version> <scope>provided</scope> </dependency> |
My Mule config file looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd"> <description> Proxies a Web Service </description> <custom-transformer name="my-transformer" class="nl.redstream.proxy.wsproxy.MyTransformer" /> <object-to-string-transformer name="ObjectToStringTransformer" /> <pattern:web-service-proxy name="my-order-ws-proxy" inboundAddress="http://Pascal-Almas-MacBook-Pro.local:8090/my-order" responseTransformer-refs="ObjectToStringTransformer my-transformer" outboundAddress="http://Pascal-Almas-MacBook-Pro.local:8088/mockDataServiceSoapBinding" /> </mule> |
To run the Mule application just make sure your Mule installation is running and in your project execute the command ‘mvn clean install’
You should see a message in your Mule console like this:
Now we can put the proxy at work by redirecting the SoapUI request to the url: http://Pascal-Almas-MacBook-Pro.local:8090/my-order. It should the be forwarded to the original url and the translator I put in between should output the content to the Mule console:
However if you try this for the first time big chance you will run into this issue (at least I did). To get around this issue modify the soapUI settings like this:

Hello,
I use Mule ( as tester), however, I could able to see all the HTTP wire content in Mule.log file,when you enable log4j configurations.
Whats the real use of proxying and soapui , please let me know.
Thanks !
Karthi
mkarthi@gmail.com
Hello Karthik,
thanks for your comment.
The reason I used the proxy pattern with Mule was that in the original setup the web service was called directly by a client application. So I was not able to log anything. Therefore I put Mule in the middle so I could log what was passed to and from the service. To output the info I used a transformer where you suggest I could have the same by configuring log4j. I didn’t know that so that’s good to know now.
The reason I used SoapUI was just to show how Mule behaves in this case. I wasn’t able to use the ‘real life’ web service so I mimicked the service with soapUI.
For more info about when to use the web service proxy pattern see this: http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern
Hope this clarifies things.
Regards,
Pascal