Mule – Building a webservice proxy

In this blogpost we’ll develop a simple webservice proxy using the latest Mule Studio Community Edition (currently version 1.3.1 which uses Mule ESB v.3.3), which can be downloaded here. The proxy will do some basic routing. No transformation will be done. That area will be explored in a future blogpost.

webservice proxy
mule proxy service

The webservice which will be used for proxying is a simple jax-ws webservice for retrieving employee data based on their department id. The webservice will be exposed via the following url: http://localhost:8083/HR/hrManagerService?wsdl. See this blogpost for building a simple jax-ws webservice on your own.

Creating a new Mule project

First we’ll create a new Mule project based on Maven. This can be done in 3 simple steps. First select File > New > Mule Project. Give the project a Name and a Description and click Next >.

Screenshot from 2013-01-03 12:35:35
New Mule Project – Step 1 of 3

Now, create a flow for the project. Give it a Name, File name and a Description and click Next >.

Screenshot from 2013-01-03 12:35:55
New Mule Project – Step 2 of 3

Finally select the option for creating the Maven pom.xml file and fill in a Group Id and Artifact Id and click Finish.

Screenshot from 2013-01-03 12:39:13
New Mule Project – Step 3 of 3

That’s all. We’ve created the skeleton for our web service proxy and are now ready to implement the flow.

Building the flow

Open the mule-proxy.mflow file and drag a Flow Scope into it. Give it an appropriate name, like MuleProxyFlow.


Now let’s build the flow for the proxy service back to front. We’ll begin with adding a HTTP Endpoint to the flow which will resemble the webservice we’re gonna proxy. Right click the Endpoint and select Convert to an outbound endpoint. Next select Properties, clear the Host and Port values and fill in the endpoint of the webservice in the Address field.

Screenshot from 2013-01-03 14:34:20
HTTP Outbound Endpoint Properties – General
Screenshot from 2013-01-03 14:41:01
HTTP Outbound Endpoint Properties – Advanced

Next, we’ll create a client for the web service. Select a SOAP Component and drag it to the left of the HTTP Endpoint. Change the Operation field to Proxy client.

Screenshot from 2013-01-03 14:54:31
SOAP Component – Proxy client

Now for the actual proxy service. Select another SOAP Component and drag it to the left of the Proxy client SOAP Component. Change the Operation to Proxy service. Fill in the Namespace and Service as well. They have to match the targetNamespace and name of the webservice as defined in the wsdl we’re gonna use for the proxy. Make sure that the Payload of the Proxy service and Proxy client match (in this example I choose to only exchange the SOAP body).

Screenshot from 2013-01-03 15:12:52
SOAP Component – Proxy service – General

In the Advanced section we’ll fill in the WSDL Location of the actual wsdl, which will serve as the wsdl for the proxy service. In this simple example, the wsdl of the proxy will match the wsdl of the actual webservice. I’ve raken the liberty to copy the wsdl and xsd files to the src/main/resources/wsdl and src/main/resources/xsd directories of the project. But for the sake of simplicity, you could also pick up the wsdl from it’s actual location, i.e. http://localhost:8083/HR/hrManagerService?wsdl and use that as the WSDL Location in the case of this example.

Screenshot from 2013-01-03 17:57:42
SOAP Component – Proxy service – Advanced

Finally, we’ll need to add the HTTP inbound endpoint. Again, clear the Host and Port fields and add the Address you’d like to use for the proxy, in this example it will be http://localhost:8081/hrManagerServiceProxy.

Screenshot from 2013-01-03 15:27:38
HTTP Inbound Endpoint Properties – General
Screenshot from 2013-01-03 15:27:50
HTTP Inbound Endpoint Properties – Advanced

That’s it. If you followed these steps correctly, your flow should resemble the flow below.


The xml configuration (src/main/app/mule-proxy.xml) should look like the code below.

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:cxf="" xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" version="CE-3.3.0" xmlns:xsi="" xsi:schemaLocation=" ">
  <flow name="MuleProxyFlow" doc:name="MuleProxyFlow">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8081/hrManagerServiceProxy" doc:name="HTTP"/>
    <cxf:proxy-service namespace="" service="HRManagerServiceImplService" payload="body" doc:name="SOAP" enableMuleSoapHeaders="false" wsdlLocation="wsdl/hrManagerService.wsdl"/>
    <cxf:proxy-client doc:name="SOAP" payload="body"/>
    <http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8083/HR/hrManagerService" doc:name="HTTP"/>

Testing the proxy

Mule Studio

Now, let’s run the Mule proxy. You can do this directly inside Mule Studio by choosing Run As > Mule Application.


You can also use maven via the command line:

mvn clean install

There’s a small issue with the generated pom.xml file in this version of the Community Edition. If you use it as is, you’ll get an error concerning missing dependencies. To fix this, open the pom.xml file and search for the following snippet:

<!-- Xml configuration -->

Replace it with this one:

<!-- Xml configuration -->

Also you need to have a mule server running for this to work. See this blogpost for details. The install goal will deploy the mule project to the $MULE_HOME/apps directory of the mule server installation and if the server is running, it wil startup the project automatically.


Regardless of the way you’re running the mule project, be it via Maven or via Mule Studio, you should be able to test the proxy now with soapUI. Create a New Project, point it to the wsdl of the proxy, i,e. http://localhost:8081/hrManagerServieProxy?wsdl, and add a default TestSuite. Now you can run a TestCase against the proxy and it should yield the same result as it would when you’d call the webservice behind it directly.

Screenshot from 2013-01-03 21:26:50
soapUI – Testing the proxy


In this blogpost we’ve created a simple webservice proxy which does some basic routing without any kind of transformation. In the next post we’ll add some transformation and basic logging to the mix.


10 thoughts on “Mule – Building a webservice proxy

  1. 🙂 Thanks for the tutorial-works like a gem,

    I just wanted to know why you’re including the second SOAP Component and changing its Operation to “Proxy Client” because I realise without it get Exception on my SOAP Request.


  2. Hi Roger, Thanks for the explanation.
    I have some extra requirement apart from what is explained above. I need to configure my WS-security keystore and certificates in the process flow. Where , at which activity should i configure them? Is it at SOAP component ?

    Neha Mishra

      • Hi Alma,

        I am trying to create web service client and in the client process i want to add WS-security and certificates. The link you have given above tells the configuration of WS-security on server side i believe as it validates the user name token.
        My server call is a secured one i.e HTTPS, so i have added my keystore.jks in outbound HTTP request. I am not sure if i did that correct?

        Secondly i also have user name, password and timestamp to add into the request which should be part of the WS-security.

        Could you please help me where in the above process i can add WS-security. It would be really great. I am really stuck on this issue from last few weeks,


  3. Hi Alma,

    Thanks for the explanation but i am really not a java person. I am trying to configure it from Studio components.

    I have 2 main questions:
    Q1. In which component do i configure my keystore.jks?
    Right now i am doing it in the HTTP outbound component. I configured a HTTP connector and provided path to my keystore.jks file.

    Q2. Where do i configure outgoing WS-security, i need to add 2 types of entry : Timestamp and Username.

    Could you please explain me in studio components only rather than back end Java code. That would be great help.

    Neha Mishra

  4. Hi, and thanks for your post but I get an authorization error…

    org.mule.transport.http.HttpClientMessageDispatcher: Received a redirect, but followRedirects=false. Response code: 407 Proxy Authorization Required

    I’m working just on a local example and all the addresses point to localhost so there should be no proxy in between… Still I get this error… Any clue on what I could be doing wrong?
    Thanks a lot

  5. Man am I glad I found this blog post. I don’t know why it was so hard for me to find it, but it’s about the only step-by-step example of setting up Mule to consume (at least in some form) an existing web service. Mule’s own docs are next to useless. Thanks!

    Now I have to ask, when is that “next post” coming, where you cover transformations, etc. 😀

  6. Nice Tutorial but I am stuck at a point in the project. I can’t connect to the HTTP outbound point and the error says that HTTP outbound point refused to Connect. Please Help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s