Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Consume SOAP-Based Web Service With Mulesoft Anypoint Studio

DZone's Guide to

How to Consume SOAP-Based Web Service With Mulesoft Anypoint Studio

Consuming SOAP-based web services with Anypoint Studio is easy. Doing so assists serialization and deserialization as well as SOAP envelope and namespace processing.

· Integration Zone
Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements.  What’s below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

CXF is a Java web services framework used for SOAP (Simple Object Access Protocol) messaging. It handles all serialization and deserialization as well as SOAP envelope and namespace processing.

Now, we will walk through how to consume SOAP-based web services with Anypoint Studio.

Consume SOAP-Based Web Service

Place an HTTP listener in the source section of the flow and configure it as shown below.

Image title

Now place the Web Service Consumer components to the message processor in flow and configure the components. Click Add Connector Configuration and it will open another window. You can provide your WSDL Location (it can web service URL or any physical WSDL location) and click Reload WSDL. It will automatically fill the Service, Port, and Address for you. Press OK.

Image title

Now, you need to select one Operation that you need to perform on the Web Service. In my case, I will use findFlights. This operation is expecting one argument: destination.

Image title

Passing Arguments to Web Service

We are expecting the destination as a query parameter in input request via the HTTP listener and will store query parameter in flow variable.

Image title

Place TransformMessage between FlowVariable and Web Service Consumer and you can see that the output metadata in DataWeave is generated automatically. You can also see the input data with the flow variable that we defined previously. We will map the destination from FlowVariable to the destination argument required by Web Service.

Image title

Transform Response From Web Service 

Now we will place the one more TransformMessage after Web Service Consumer to map XML result from Web Service to JSON format. You can see input metadata in DataWeave is generated automatically. You can define output metadata as per your requirements and perform mapping.

Image title

Testing the Application

You can use Postman to test the application. First, deploy the application with Anypoint Studio.

Now, we will use the HTTP GET method in Postman to send a request to the HTTP listening to this URL.

Image title

Now, you know how to consume SOAP-based web services with Anypoint Studio!

Here is the video tutorial.


The State of API Integration Report provides data from the Cloud Elements platform and will help all developers navigate the recent explosion of APIs and the implications of API integrations to work more efficiently in 2017 and beyond.

Topics:
mulesoft ,tutorial ,integration ,soap ,web service ,anypoint studio

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}