SlideShare a Scribd company logo
Web Service Invocation in Mule
This Tutorial explains how to consume a
webservice using mule Web Service Consumer.
Pre-requisites:
● Anypoint Studio
● Weather Web Service
In the below flow I am setting the city zip code as payload in
“Set Payload” Component.
DataMapper component maps this value to the Weather
Webservice Operation “GetCityForecastByZip” Request xml
Field as “ZIP”.
Webservice Consumer component calls the Weather Web
Service to fetch the “GetCityForecastByZipResponse”.
The Next DataMapper Transforms the XML to POJO Object
i.e. GetCityForecastByZipResponse (Used for testing purpose
only, Can be removed).
Finally GetCityForecastByZipResponse Java Object will be
transformed to JSON String and given as response to Http
Component.
Which gives the City Weather Information
Main Flow
Http Component Configuration
Set Payload Component
Configuration
DataMapper to prepare Web
Service Request
Web Service Consumer
Configuration
Web Service Configuration
DataMapper to Transform
Webservice Response to POJO
Configuration
Web service invocation in mule
Main Flow Source
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="Weather.wsdl"
service="Weather" port="WeatherSoap12"
serviceAddress="http://wsf.cdyne.com/WeatherWS/Weather.asmx" doc:name="Web
Service Consumer"/>
<!-- <mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="wet" uri="http://ws.cdyne.com/WeatherWS/"/>
</mulexml:namespace-manager> -->
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import name="poc" class="com.poc.PocUtil"/>
<global-functions>
def changeState(){ return poc.changeState() }
</global-functions>
</expression-language>
</configuration>
<data-mapper:config name="JSON_To_Xml_GetCityWeatherByZIP_"
transformationGraphPath="json_to_xml_getcityweatherbyzip_.grf"
doc:name="JSON_To_Xml_GetCityWeatherByZIP_"/> <data-mapper:config
name="JSON_To_Xml_GetCityForecastByZIP_"
transformationGraphPath="json_to_xml_getcityforecastbyzip_.grf"
doc:name="JSON_To_Xml_GetCityForecastByZIP_"/>
<data-mapper:config name="Xml_GetCityForecastByZIPResponse__To_Pojo"
transformationGraphPath="xml_getcityforecastbyzipresponse__to_pojo.grf"
doc:name="Xml_GetCityForecastByZIPResponse__To_Pojo"/>
<flow name="webservicepocFlow2" doc:name="webservicepocFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8082" doc:name="HTTP"/>
<set-payload value="{&quot;zipcode&quot;:&quot;00501&quot;}" doc:name="Set
Payload"/>
<data-mapper:transform config-ref="JSON_To_Xml_GetCityForecastByZIP_"
doc:name="JSON To Xml&lt;GetCityForecastByZIP&gt;"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="GetCityForecastByZIP"
doc:name="Web Service Consumer"/>
<data-mapper:transform config-ref="Xml_GetCityForecastByZIPResponse__To_Pojo"
doc:name="Xml&lt;GetCityForecastByZIPResponse&gt; To Pojo">
<data-mapper:input-arguments>
</data-mapper:input-arguments>
</data-mapper:transform>
<logger message="#[payload.getCity()]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>

More Related Content

PPTX
Making flow Mule
PPTX
Custom connector development using mule DevKit
PPT
Mule real-world-old
PPT
Mule execution
PPTX
Mulesoft Soap Service
PPTX
Concepts in mule
PPTX
Junit in mule demo
PPTX
Mule esb whole_web_services
Making flow Mule
Custom connector development using mule DevKit
Mule real-world-old
Mule execution
Mulesoft Soap Service
Concepts in mule
Junit in mule demo
Mule esb whole_web_services

What's hot (20)

PPTX
Mule Microsoft Dynamics AX 2012 Connector
PPTX
ESB Online Training Part 2
PPTX
Enjoy Munit with Mule
PPTX
Mulesoft Anypoint platform introduction
PPTX
Mule Concur Connector
PPTX
Mule components
PPT
Mule and web services
PPTX
For each component in mule demo
PDF
Introduction to SOAP/WSDL Web Services and RESTful Web Services
PPTX
Java mule
PPTX
Mule agent architecture
ODP
Interoperable Web Services with JAX-WS
PDF
Java web services using JAX-WS
PDF
Spring integration
PPTX
SOAP Service in Mule Esb
PDF
Java API for XML Web Services (JAX-WS)
PPT
Maven introduction in Mule
PPT
WebService-Java
PPTX
Messaging with Spring Integration
PPT
Spring MVC Basics
Mule Microsoft Dynamics AX 2012 Connector
ESB Online Training Part 2
Enjoy Munit with Mule
Mulesoft Anypoint platform introduction
Mule Concur Connector
Mule components
Mule and web services
For each component in mule demo
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Java mule
Mule agent architecture
Interoperable Web Services with JAX-WS
Java web services using JAX-WS
Spring integration
SOAP Service in Mule Esb
Java API for XML Web Services (JAX-WS)
Maven introduction in Mule
WebService-Java
Messaging with Spring Integration
Spring MVC Basics
Ad

Viewers also liked (14)

PPTX
Primer parcial dfso
PPTX
Mule with rabbit mq
PPTX
How to – rest api proxy to soap webservice
PDF
Seleccionados SOLF nº16 (Xuño 2016)
PDF
Boletín de novidades. Sección infantil-xuvenil. Setembro-outubro 2016
PPTX
Ford car on the cloud
PDF
CES 2017 Show Floor Maps
PDF
Calcio. Registrazione del lavoro di allenamento e della partita
PPTX
HANDWRITTEN DIGIT RECOGNITION USING k-NN CLASSIFIER
PPTX
Does Pronunciation Instruction Promote Intelligibility and Comprehensibility?
PDF
L05 language model_part2
PPSX
Projekt Edukacja bez granic
PDF
Machine Learning Lecture 2 Basics
PPTX
GIS Services development using CloudEO platform data and Tools
Primer parcial dfso
Mule with rabbit mq
How to – rest api proxy to soap webservice
Seleccionados SOLF nº16 (Xuño 2016)
Boletín de novidades. Sección infantil-xuvenil. Setembro-outubro 2016
Ford car on the cloud
CES 2017 Show Floor Maps
Calcio. Registrazione del lavoro di allenamento e della partita
HANDWRITTEN DIGIT RECOGNITION USING k-NN CLASSIFIER
Does Pronunciation Instruction Promote Intelligibility and Comprehensibility?
L05 language model_part2
Projekt Edukacja bez granic
Machine Learning Lecture 2 Basics
GIS Services development using CloudEO platform data and Tools
Ad

More from AnilKumar Etagowni (9)

PPT
Spring introduction
ODP
Mule ESB : ssh connector
PPTX
Mule esb data weave multi input data
PPTX
Mule esb :Data Weave
ODP
Mule ESB SMTP Connector Integration
ODP
Box connector Mule ESB Integration
ODP
Dropbox connector Mule ESB Integration
ODP
Running ms sql stored procedures in mule
ODP
Fetch records from mysql using mule esb
Spring introduction
Mule ESB : ssh connector
Mule esb data weave multi input data
Mule esb :Data Weave
Mule ESB SMTP Connector Integration
Box connector Mule ESB Integration
Dropbox connector Mule ESB Integration
Running ms sql stored procedures in mule
Fetch records from mysql using mule esb

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Types and Its function , kingdom of life
PDF
01-Introduction-to-Information-Management.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Pre independence Education in Inndia.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Lesson notes of climatology university.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Insiders guide to clinical Medicine.pdf
VCE English Exam - Section C Student Revision Booklet
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
Anesthesia in Laparoscopic Surgery in India
TR - Agricultural Crops Production NC III.pdf
Pharma ospi slides which help in ospi learning
Cell Types and Its function , kingdom of life
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Microbial disease of the cardiovascular and lymphatic systems
Microbial diseases, their pathogenesis and prophylaxis
Pre independence Education in Inndia.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Sports Quiz easy sports quiz sports quiz
Lesson notes of climatology university.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Insiders guide to clinical Medicine.pdf

Web service invocation in mule

  • 1. Web Service Invocation in Mule This Tutorial explains how to consume a webservice using mule Web Service Consumer. Pre-requisites: ● Anypoint Studio ● Weather Web Service
  • 2. In the below flow I am setting the city zip code as payload in “Set Payload” Component. DataMapper component maps this value to the Weather Webservice Operation “GetCityForecastByZip” Request xml Field as “ZIP”. Webservice Consumer component calls the Weather Web Service to fetch the “GetCityForecastByZipResponse”. The Next DataMapper Transforms the XML to POJO Object i.e. GetCityForecastByZipResponse (Used for testing purpose only, Can be removed). Finally GetCityForecastByZipResponse Java Object will be transformed to JSON String and given as response to Http Component. Which gives the City Weather Information
  • 6. DataMapper to prepare Web Service Request
  • 9. DataMapper to Transform Webservice Response to POJO Configuration
  • 11. Main Flow Source <ws:consumer-config name="Web_Service_Consumer" wsdlLocation="Weather.wsdl" service="Weather" port="WeatherSoap12" serviceAddress="http://wsf.cdyne.com/WeatherWS/Weather.asmx" doc:name="Web Service Consumer"/> <!-- <mulexml:namespace-manager includeConfigNamespaces="true"> <mulexml:namespace prefix="wet" uri="http://ws.cdyne.com/WeatherWS/"/> </mulexml:namespace-manager> --> <configuration doc:name="Configuration"> <expression-language autoResolveVariables="true"> <import name="poc" class="com.poc.PocUtil"/> <global-functions> def changeState(){ return poc.changeState() } </global-functions> </expression-language> </configuration> <data-mapper:config name="JSON_To_Xml_GetCityWeatherByZIP_" transformationGraphPath="json_to_xml_getcityweatherbyzip_.grf" doc:name="JSON_To_Xml_GetCityWeatherByZIP_"/> <data-mapper:config name="JSON_To_Xml_GetCityForecastByZIP_" transformationGraphPath="json_to_xml_getcityforecastbyzip_.grf" doc:name="JSON_To_Xml_GetCityForecastByZIP_"/>
  • 12. <data-mapper:config name="Xml_GetCityForecastByZIPResponse__To_Pojo" transformationGraphPath="xml_getcityforecastbyzipresponse__to_pojo.grf" doc:name="Xml_GetCityForecastByZIPResponse__To_Pojo"/> <flow name="webservicepocFlow2" doc:name="webservicepocFlow2"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/> <set-payload value="{&quot;zipcode&quot;:&quot;00501&quot;}" doc:name="Set Payload"/> <data-mapper:transform config-ref="JSON_To_Xml_GetCityForecastByZIP_" doc:name="JSON To Xml&lt;GetCityForecastByZIP&gt;"/> <ws:consumer config-ref="Web_Service_Consumer" operation="GetCityForecastByZIP" doc:name="Web Service Consumer"/> <data-mapper:transform config-ref="Xml_GetCityForecastByZIPResponse__To_Pojo" doc:name="Xml&lt;GetCityForecastByZIPResponse&gt; To Pojo"> <data-mapper:input-arguments> </data-mapper:input-arguments> </data-mapper:transform> <logger message="#[payload.getCity()]" level="INFO" doc:name="Logger"/> <json:object-to-json-transformer doc:name="Object to JSON"/> </flow>