DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Consuming SOAP Service With Apache CXF and Spring
  • Web Service Testing Using Neoload
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • How to Consume REST Web Service (GET/POST) in Java 11 or Above

Trending

  • Manual Sharding in PostgreSQL: A Step-by-Step Implementation Guide
  • How to Perform Custom Error Handling With ANTLR
  • Memory Leak Due to Time-Taking finalize() Method
  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Consuming SOAP Web Services Using Mule

Consuming SOAP Web Services Using Mule

All you need to consume a SOAP-based public web service from Mule Anypoint Studio is a WSDL to locate the SOAP-based web service.

By 
Danish Sheikh user avatar
Danish Sheikh
·
Mar. 13, 17 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
50.0K Views

Join the DZone community and get the full member experience.

Join For Free

Mule's web service consumer is a ready-made connector that can connect to a SOAP service provider. All it needs is a WSDL to locate the SOAP-based web service.

1. Discover the SOAP Web Service

In order to consume a web service, we need to discover it first. We need to get the WSDL of the web service in order to consume it. For this example, we will use the temperature conversion web service hosted by w3schools. It is public and free to use. You can find it here.

This provides two operations for temperature conversion as shown below:

Operations Exposed by TempConvert W3School Webservice

2. Consume the SOAP Web Service Using Mule Studio

Mule Studio provides HTTP connector for reading the WSDL and extracting the metadata of the web service.

Create a new Mule project. Go to File > New > Mule Project.

Creating New Mule Project

Name the project as soap_webservice_consumer. 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.

HTTP Configuration

In Properties window, keep the path as the default / and type Allowed Methods as GET.

Click the green + sign next to Connector Configuration dropdown. You can see the Global Elements Properties window pop up. Many fields are prepopulated. For now, we use the default host and port.

Setting HTTP host and port

Click OK. Now drag and drop a web service consumer from the Mule palette onto the canvas. Click Web Service Consumer to configure its properties. Below, you can see the Web Service Consumer properties window.

Web Service Consumer Properties

Click green + sign next to Connect Configuration. This will open a Global Element Properties window as shown below.

Getting wsdl metadata

Let's set WSDL Location with the value https://www.w3schools.com/xml/tempconvert.asmx?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.

Global Element Properties for Web Service Consumer

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, the TempConvert exposes two operations: CelsiusToFahrenheit and FahrenheitToCelsius. Choose CelsiusToFahrenheit from dropdown as we will need to convert Celsius to Fahrenheit.

Choose operation in Web Service Consumer

Drag and drop a variable element from the Mule palette between HTTP and Web Service Consumer. This will capture the query parameter temp in the URL and assign it to FlowVar inputTemp as shown below:

Parsing Input Request

 Drag and drop a transform message from the Mule palette, after the variable. Assign inputTemp   to ns0:Celsius: String as shown below. This will set the input for the SOAP request, which will be sent to the web service.

Setting SOAP request

That's it! Let's send some requests to convert Celsius to Fahrenheit to the SOAP web service. Run the project.

Image title

Let's send a request to our mule flow using chrome. For this we will convert 34 degree Celsius to Fahrenheit.

Type localhost:8081/?temp=34 in the address bar and hit enter. We will get the SOAP response with the converted temperature in Fahrenheit.

Testing the application

We have successfully consumed a SOAP-based public web service from Anypoint Studio.

Web Service SOAP Web Protocols

Opinions expressed by DZone contributors are their own.

Related

  • Consuming SOAP Service With Apache CXF and Spring
  • Web Service Testing Using Neoload
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • How to Consume REST Web Service (GET/POST) in Java 11 or Above

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!