<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>redstream &#187; SoapUI</title>
	<atom:link href="http://www.redstream.nl/category/technical/soap-ui-technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redstream.nl</link>
	<description>Pragmatic Integrators</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Set up Web Service Proxy with Mule3</title>
		<link>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/</link>
		<comments>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 14:06:48 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Mule3]]></category>
		<category><![CDATA[SoapUI]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2826</guid>
		<description><![CDATA[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 &#8230; <a href="http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F09%2F24%2Fset-up-web-service-proxy-with-mule3%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>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 <a href="http://www.mulesoft.org/">Mule ESB</a>. 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&#8217;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 <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">this article</a>.<br />
<span id="more-2826"></span><br />
To get started I downloaded the <a href="http://www.mulesoft.org/download-mule-esb-community-edition">Mule Standalone edition</a> here and installed it. That isn&#8217;t very hard, just untar the thing and set the MULE_HOME property. Go to the bin directory and give &#8216;./mule&#8217; and off you go (except for a warning when running on MacOS 64-bit, but it doesn&#8217;t seem to harm so far…):<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/warning.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/warning-300x222.jpg" alt="" title="warning" width="300" height="222" class="aligncenter size-medium wp-image-2829" /></a></p>
<p>To create a test web service I setup a MockService in SoapUI. Like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.45.06-300x193.jpg" alt="" title="SoapUI MockService" width="300" height="193" class="aligncenter size-medium wp-image-2846" /></a><br />
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:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.47.54-300x137.jpg" alt="" title="SoapUi Response" width="300" height="137" class="aligncenter size-medium wp-image-2847" /></a></p>
<p>Next step is create a new Mule project (I still favor <a href="http://maven.apache.org/">Maven</a> above the <a href="http://www.mulesoft.org/documentation/display/MULESTUDIO/Home">Mule Studio</a>):</p>
<ul>
<li>create new Maven project with</li>
<p><code>mvn mule-project-archetype:create -DartifactId=WSProxy -DmuleVersion=3.1.2</code></p>
<li>Set up the WS Proxy</li>
<p>To create WS Proxy I followed the description <a href="http://www.mulesoft.org/documentation/display/MULE3USER/Web+Service+Proxy+Pattern">here</a><br />
Note: to make use of the pre-defined &#8216;pattern&#8217; you must add the following dependency to the pom:</p>

<div class="wp_codebox"><table><tr id="p28263"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2826code3"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.mule.patterns<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-patterns-all<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>My Mule config file looks like this:</p>

<div class="wp_codebox"><table><tr id="p28264"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2826code4"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/core&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:pattern</span>=<span style="color: #ff0000;">&quot;http://www.mulesoft.org/schema/mule/pattern&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd</span>
<span style="color: #009900;">        http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    Proxies a Web Service
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-transformer&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.proxy.wsproxy.MyTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object-to-string-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pattern:web-service-proxy</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;my-order-ws-proxy&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">inboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8090/my-order&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">responseTransformer-refs</span>=<span style="color: #ff0000;">&quot;ObjectToStringTransformer my-transformer&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">outboundAddress</span>=<span style="color: #ff0000;">&quot;http://Pascal-Almas-MacBook-Pro.local:8088/mockDataServiceSoapBinding&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<li>Fire up the proxy</li>
<p>To run the Mule application just make sure your Mule installation is running and in your project execute the command &#8216;mvn clean install&#8217;<br />
You should see a message in your Mule console like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-07-at-21.25.54-300x82.jpg" alt="" title="Mule console" width="300" height="82" class="aligncenter size-medium wp-image-2840" /></a>
</ul>
<p>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:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-15.57.57-300x114.jpg" alt="" title="MuleLogging" width="300" height="114" class="aligncenter size-medium wp-image-2849" /></a> </p>
<p>However if you try this for the first time big chance you will run into <a href="http://www.mulesoft.org/jira/browse/MULE-5363">this</a> issue (at least I did). To get around this issue modify the soapUI settings like this:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52.jpg"><img src="http://www.redstream.nl/wp-content/uploads/2011/09/Screen-Shot-2011-09-24-at-16.01.52-300x219.jpg" alt="" title="soapui-prefs" width="300" height="219" class="aligncenter size-medium wp-image-2850" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/09/24/set-up-web-service-proxy-with-mule3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

