Home
- Home
- Blog
Author :
Global TechHub
Introduction
Consuming SOAP-based web services with
Anypoint Studio is easy. Doing so assists serialization and deserialization as
well as SOAP envelope and namespace processing. The Web Service Consumer (WSC)
connector consumes a SOAP Web service to acquire data from an external source.
In many cases, you can use an existing MuleSoft connector, such as Workday or
Service Now, to connect to a service provider. However, when no connector
available for a specific Web service, the easiest way to consume the service
from a Mule app is to use the Web Service Consumer connector.
Overview
The main features of this connector include:
Ø Consuming DOC Literal Web services.
Ø
SOAP multipart messages.
Ø
SOAP Headers.
Ø
DataSense support for SOAP Headers,
SOAP Body, and Attachment.
Ø
Embedded DataWeave transformations
inside the operation.
Ø
Support and Unified experience for
SOAP with attachments and MTOM handling.
Ø
Custom HTTP configuration as
transport (Runtime and Design Time).
Ø WS Securities support.
Create Mule Project
Create a new Mule project. Go to
File > New > Mule Project.
Name the project as flights-ws-consumer-services. Click Finish.
On the canvas, drag an HTTP connector as
shown below. Click HTTP Connector on the canvas to configure its properties.
Below, next to the Console window, you can see HTTP properties window as well.
In Properties window, keep the path as /flights.
Click the green + sign next to Connector Configuration drop down. You
can see the Global Elements Properties window
pop up. Many fields are pre-populated. For now, we use the default host, port
and enter Base Path as /api.
Click OK.
Now Click on Add Modules drag and drop a
web service consumer from the Mule palette to add into Project. Now drag and
drop Consume from Mule palette to canvas.
Click Consume to configure its properties.
Below, you can see the Consume properties window.
Click green + sign next to Connect Configuration. This will
open a Global Element Properties window as shown below.
Let's set WSDL Location with the value http://mu.learn.mulesoft.com/delta?wsdl.
Service, port, and address are automatically
populated by the Web Service Consumer Connector based on the value of WSDL
location. If there are multiple services hosted on the same
"location," then you can choose from the service drop-down
accordingly.
Back to the Mule design. You can see that
Connector Configuration is set to the global Web_Service_Consumer element.
Just below that, choose the operation that
you want to call. In our case, in our web services exposes two operations: findFlight and listAllFlights. Choose findFlight
from dropdown as we will need to get the flight details based on Destination as
Input.
Drag and drop a set variable element
from the Mule palette between HTTP and Consume. This will capture the query
parameter destination in the URL and
assign it to variable called inputDestination
as shown below:
Drag and drop a transform message from the
Mule palette, after the variable. Assign inputDestination
to destination: String as shown
below. This will set the input for the SOAP request, which will be sent to the
web service.
Drag and drop a transform message from the
Mule palette, after the Consume. Convert the payload to Json formate as shown
below. This will set the response as Json from the SOAP response.
That's it! Let's deploy the application. Right
click on project Run As à Mule Application.
This we steps deploys our application in
MuleSoft embabed server. Let's send a request to our mule flow using chrome.
For this we will get the Flight details for destination ‘SFO’.
Type http://localhost:8081/api/flights?destination=SFO
in the address bar and hit enter. We will get the SOAP response with the
converted json format.
We have successfully consumed a SOAP-based public web service
from Anypoint Studio.
Conclusion
All we have done is consume a SOAP-based
public web service from Mule Anypoint Studio is a WSDL to locate the SOAP-based
web service. I will show how to consume private Web Services with security and
proxy configuration in my upcoming articles. Keep on watch this place for more
articles.
Download
S. No
|
File Name
|
Size
|
Download
|
1
|
Consuming SOAP Web Services Using Mulesoft 4.pdf
|
1.0 MB
|
|
2
|
flights-ws-consumer-services.zip
|
15 MB
|
Comments
Post a Comment