How to use the Web Service Consumer connector behind a proxy

Introduction: using proxy configuration in Mule with HTTP

A lot of companies are connecting to the web via a proxy, most of the times all the traffic to the outside world is routed through a proxy before it reaches the destination.

So employees have setup the proxy configuration in their web browsers so all the requests are sent via the proxy.

In Mule, outgoing HTTP requests are similar to request from a browser so most of the times the proxy configuration needs to be used.

In the Global HTTP Request Configuration the proxy can be configured in the Proxy tab.

In the screenshot both the host and port are (of course) example values, username and password maybe necessary in your scenario.

http_request_proxy_config

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So when using an HTTP outbound endpoint and you refer to this Global Configuration your traffic is routed via the proxy config you provided.

Web Service Consumer behind a proxy

Using the Web Service Consumer connector to consume SOAP webservices with Mule is very simple and effective.

When using a Web Service Consumer connector you need to add a Global Connector Configuration, as with most of the connectors in Mule.

The only thing that you need to provide a WSDL file, that can be a file that is accessible via the web or a file that is stored locally in your Mule project.

In this example i used a WSDL file that is public available via the following URL:

http://www.webservicex.com/CurrencyConvertor.asmx?wsdl

The other fields are populated automatically when the WSDL is parsed.

wsc_global_config

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Because all traffic needs to be routed via the proxy, that is also the case with this SOAP webservice, it a call and a response over HTTP.

There is no Proxy tab in the Global configuration of the Web Service Consumer connector.

Well here is the trick, you need to setup to a HTTP Request Configuration that contains the host settings of the web service and the proxy configuration.

So in the case of the provided example that will be:

General Config

http_request_config_wsc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Proxy Config

Again, in the screenshot both the host and port are (of course) example values, username and password maybe necessary in your scenario.

http_request_proxy_config

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next step is to refer to the created HTTP Request Configuration at the Web Service Consumer Global Element.

wsc_config_reference

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Using proxy settings on Mule ESB server instances

When you run Mule ESB instances on premise the proxy settings can be passed in as JVM parameters.
Best way to do this is by adding them in the wrapper.conf file
$MULE_HOME/conf/wrapper.conf

Example with the values from the previous steps
wrapper.java.additional.=-Dhttp.proxyHost=my.example.proxy.com
wrapper.java.additional.=-Dhttp.proxyPort=8080

Make sure you change to the next available number, default is 15, 16

Example application

wsc-proxy-flow

 

 

 

 

 

 

You can use the code in Anypoint Studio

When using the code you will see the Global HTTP Request Configuration.

In the flow it won’t show up, you will only reference it via the Web Service Consumer Connector

Test it:
Pass in a query parameter (eg. CAD/USD/GBP)

example: http://localhost:8081?from=USD

Change the proxy settings, watch the connectorConfig attribute on the ws:consumer-config

Leave a Reply

Your email address will not be published. Required fields are marked *