SlideShare a Scribd company logo
1 of 14
Rest Services In Mule
By,
Keshav
Rest Full Webservice
● A web service is a collection of open protocols and standards
used for exchanging data between applications or systems
● Web services based on REST Architecture are known as
RESTful Web Services. These web services use HTTP methods
to implement the concept of REST architecture.
● A RESTful web service usually defines a URI (Uniform
Resource Identifier), which is a service that provides resource
representation such as JSON and a set of HTTP Methods.
HTTP Methods:
● The following HTTP methods are most commonly used in a
REST based architecture.
>GET − Provides a read only access to a resource.
>PUT − Used to update the existing resource.
>DELETE − Used to remove a resource.
>POST − Used to update an existing resource or create a new
resource.
REST service in MULE:
● In the context of web services, this generally means that
RESTful web services communicate via pure HTTP using
XML or JSON to encapsulate the data and metadata.
Publishing/Implementing a Rest Service: Two ways
1) APIkit
- APIkit can create an API based on a RAML (RESTful API
Modeling Language) API definition and produces a Mule
application with an HTTP endpoint, exception strategies
2) REST component:
- Use a REST API to publish an external RESTful web service.
- A REST component publishes a RESTful web service via
JAX-RS annotations and using Jersey by specifying the REST
component class.
Consuming a REST service:
To consume a REST API using Mule, use one of the following
techniques:
● Configure an HTTP connector to send requests to, and accept
responses from an API from within your Mule application.
● Build a connector using Anypoint Connector DevKit to perform
operations against the API.
Rest Component
● Mule hosts RESTful web services using Jersey, which is a
JAX-RS (JSR-311) implementation.
● JAX-RS is a specification that provides a series of annotations
and classes that make it possible to build RESTful services
● Using the annotations present in JAX-RS we can create unique
signatures(unique URI) for every type of request.
Annotations:
● @GET - Annotate your Get request methods with @GET
Eg: @GET
public String getHTML() {
...
}
● @Produces:specifies the type of output this method (or web
service) will produce
Eg:@GET
@Produces("application/xml")
public Contact getXML() {
...
}
● @Path: specify the URL path on which this method will be
invoked.
Eg: @GET
@Produces("application/xml")
@Path("xml/{firstName}")
public Contact getXML() {
...
● @PathParam-We can bind REST-style URL parameters to
method arguments using @PathParam annotation as shown
below.
Eg:
@GET
@Produces("application/xml")
@Path("xml/{firstName}")
public Contact getXML(@PathParam("firstName") String
firstName) {
Contact contact =
contactService.findByFirstName(firstName);
return contact;
}
● @QueryParam- Request parameters in query string can be
accessed using @QueryParam annotation as shown below.
Eg:
@GET
@Produces("application/json")
@Path("json/companyList")
public CompanyList getJSON(@QueryParam("start") int start,
@QueryParam("limit") int limit) {
CompanyList list = new
CompanyList(companyService.listCompanies(start, limit));
return list;
}
● @POST -Annotate POST request methods with @POST.
● @PUT-Annotate PUT request methods with @PUT
● @DELETE- Annotate DELETE request methods with
@DELETE.
● @Consumes-The @Consumes annotation is used to specify the
MIME media types a REST resource can consume.
Eg:
@PUT
@Consumes("application/json")
@Produces("application/json")
@Path("{contactId}")
public RestResponse<Contact> update(Contact contact) {
...
}
NOTE: used for POST and PUT operations.
Rest-Client:
● RESTClient is a simple application for talking to RESTful
web services.
● It is designed to fill a gap in existing offerings by offering
support for GET/POST/PUT/DELETE, making it a useful
tool when exploring RESTful web services which use a
wider range of HTTP verbs.
● RESTClient aims to fill this gap by allowing you to enter
*any* URL and POST/PUT/DELETE to it, you can move
data around more easily.
● By providing a simple user interface for copy pasting data,
you can fetch data from one source, copy it, change your
URL and post the data to another source.
Creating REST Clients
Rest Client in mule
● Step1: Create a rest service
- this rest service should be available for consuming it
● Step2:Consume the created rest service by creating a rest client
- write a java class for creating a rest client.
- using invoke you can call the rest client created.
Dynamic Endpoints:
● An outbound endpoint can also be dynamic. This means that the
endpoint’s URI is the value of an expression, which is
evaluated just before a message is sent to it.
● This allows the target of a message to be determined by its
contents or the value of any message property.
Dynamic endpoints can use either of the endpoint formats shown
above.
● <outbound-endpoint
address="smtp://user:secret@#[message.outboundProperties['h
ost']]"/>
● <jms:outbound-endpoint host="localhost"
queue="#[app.registry['defaultJmsQueue']]"/>
Thank You!!

More Related Content

What's hot

File connector
File connectorFile connector
File connectorkrishashi
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with muleKhan625
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mulePraneethchampion
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher akashdprajapati
 
Shipping your logs to elk from mule app/cloudhub part 2
Shipping your logs to elk from mule app/cloudhub   part 2Shipping your logs to elk from mule app/cloudhub   part 2
Shipping your logs to elk from mule app/cloudhub part 2Alex Fernandez
 
Mapping and listing in mule
Mapping and listing in muleMapping and listing in mule
Mapping and listing in muleKhan625
 
Rabbit Mq in Mule
Rabbit Mq in MuleRabbit Mq in Mule
Rabbit Mq in MuleMohammed246
 
Mule enricher component
Mule enricher component Mule enricher component
Mule enricher component Gandham38
 
Automated testing web services - part 1
Automated testing web services - part 1Automated testing web services - part 1
Automated testing web services - part 1Aleh Struneuski
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in muleSon Nguyen
 

What's hot (17)

File connector
File connectorFile connector
File connector
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
Mule Ajax Connector
Mule Ajax ConnectorMule Ajax Connector
Mule Ajax Connector
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
 
Shipping your logs to elk from mule app/cloudhub part 2
Shipping your logs to elk from mule app/cloudhub   part 2Shipping your logs to elk from mule app/cloudhub   part 2
Shipping your logs to elk from mule app/cloudhub part 2
 
Mule batch
Mule batchMule batch
Mule batch
 
Mapping and listing in mule
Mapping and listing in muleMapping and listing in mule
Mapping and listing in mule
 
Mule Complete Training
Mule Complete TrainingMule Complete Training
Mule Complete Training
 
Rabbit Mq in Mule
Rabbit Mq in MuleRabbit Mq in Mule
Rabbit Mq in Mule
 
SMTP MULE
SMTP  MULESMTP  MULE
SMTP MULE
 
Mule enricher component
Mule enricher component Mule enricher component
Mule enricher component
 
Mule parsing with json
Mule parsing with jsonMule parsing with json
Mule parsing with json
 
Automated testing web services - part 1
Automated testing web services - part 1Automated testing web services - part 1
Automated testing web services - part 1
 
Mule new jdbc component
Mule new jdbc componentMule new jdbc component
Mule new jdbc component
 
Node js crash course session 3
Node js crash course   session 3Node js crash course   session 3
Node js crash course session 3
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
 

Similar to Rest Service In Mule

RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8Gajendra Sharma
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyPayal Jain
 
53 hui homework2
53 hui homework253 hui homework2
53 hui homework2huis89
 
REST Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.pptKGSCSEPSGCT
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET Journal
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHPAndru Weir
 
Day1 : web service basics
Day1 :  web service basics Day1 :  web service basics
Day1 : web service basics Testing World
 
Restful webservices
Restful webservicesRestful webservices
Restful webservicesKong King
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State TransferPeter R. Egli
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Gaurav Bhardwaj
 
Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0Aravindharamanan S
 
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonMulti Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonJoshua Long
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swiftTim Burks
 

Similar to Rest Service In Mule (20)

Rest web services
Rest web servicesRest web services
Rest web services
 
RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8
 
REST and RESTful Services
REST and RESTful ServicesREST and RESTful Services
REST and RESTful Services
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
Mule soft ppt 3
Mule soft ppt  3Mule soft ppt  3
Mule soft ppt 3
 
53 hui homework2
53 hui homework253 hui homework2
53 hui homework2
 
REST Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.ppt
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce Site
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHP
 
Day1 : web service basics
Day1 :  web service basics Day1 :  web service basics
Day1 : web service basics
 
ExpressJS and REST API.pptx
ExpressJS and REST API.pptxExpressJS and REST API.pptx
ExpressJS and REST API.pptx
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Rest api design
Rest api designRest api design
Rest api design
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
 
Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0Secc tutorials development and deployment of rest web services in java_v2.0
Secc tutorials development and deployment of rest web services in java_v2.0
 
Angularjs & REST
Angularjs & RESTAngularjs & REST
Angularjs & REST
 
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonMulti Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
API Testing Basics.pptx
API Testing Basics.pptxAPI Testing Basics.pptx
API Testing Basics.pptx
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 

Rest Service In Mule

  • 1. Rest Services In Mule By, Keshav
  • 2. Rest Full Webservice ● A web service is a collection of open protocols and standards used for exchanging data between applications or systems ● Web services based on REST Architecture are known as RESTful Web Services. These web services use HTTP methods to implement the concept of REST architecture. ● A RESTful web service usually defines a URI (Uniform Resource Identifier), which is a service that provides resource representation such as JSON and a set of HTTP Methods.
  • 3. HTTP Methods: ● The following HTTP methods are most commonly used in a REST based architecture. >GET − Provides a read only access to a resource. >PUT − Used to update the existing resource. >DELETE − Used to remove a resource. >POST − Used to update an existing resource or create a new resource.
  • 4. REST service in MULE: ● In the context of web services, this generally means that RESTful web services communicate via pure HTTP using XML or JSON to encapsulate the data and metadata. Publishing/Implementing a Rest Service: Two ways 1) APIkit - APIkit can create an API based on a RAML (RESTful API Modeling Language) API definition and produces a Mule application with an HTTP endpoint, exception strategies 2) REST component: - Use a REST API to publish an external RESTful web service. - A REST component publishes a RESTful web service via JAX-RS annotations and using Jersey by specifying the REST component class.
  • 5. Consuming a REST service: To consume a REST API using Mule, use one of the following techniques: ● Configure an HTTP connector to send requests to, and accept responses from an API from within your Mule application. ● Build a connector using Anypoint Connector DevKit to perform operations against the API.
  • 6. Rest Component ● Mule hosts RESTful web services using Jersey, which is a JAX-RS (JSR-311) implementation. ● JAX-RS is a specification that provides a series of annotations and classes that make it possible to build RESTful services ● Using the annotations present in JAX-RS we can create unique signatures(unique URI) for every type of request. Annotations: ● @GET - Annotate your Get request methods with @GET Eg: @GET public String getHTML() { ... }
  • 7. ● @Produces:specifies the type of output this method (or web service) will produce Eg:@GET @Produces("application/xml") public Contact getXML() { ... } ● @Path: specify the URL path on which this method will be invoked. Eg: @GET @Produces("application/xml") @Path("xml/{firstName}") public Contact getXML() { ...
  • 8. ● @PathParam-We can bind REST-style URL parameters to method arguments using @PathParam annotation as shown below. Eg: @GET @Produces("application/xml") @Path("xml/{firstName}") public Contact getXML(@PathParam("firstName") String firstName) { Contact contact = contactService.findByFirstName(firstName); return contact; }
  • 9. ● @QueryParam- Request parameters in query string can be accessed using @QueryParam annotation as shown below. Eg: @GET @Produces("application/json") @Path("json/companyList") public CompanyList getJSON(@QueryParam("start") int start, @QueryParam("limit") int limit) { CompanyList list = new CompanyList(companyService.listCompanies(start, limit)); return list; } ● @POST -Annotate POST request methods with @POST. ● @PUT-Annotate PUT request methods with @PUT
  • 10. ● @DELETE- Annotate DELETE request methods with @DELETE. ● @Consumes-The @Consumes annotation is used to specify the MIME media types a REST resource can consume. Eg: @PUT @Consumes("application/json") @Produces("application/json") @Path("{contactId}") public RestResponse<Contact> update(Contact contact) { ... } NOTE: used for POST and PUT operations.
  • 11. Rest-Client: ● RESTClient is a simple application for talking to RESTful web services. ● It is designed to fill a gap in existing offerings by offering support for GET/POST/PUT/DELETE, making it a useful tool when exploring RESTful web services which use a wider range of HTTP verbs. ● RESTClient aims to fill this gap by allowing you to enter *any* URL and POST/PUT/DELETE to it, you can move data around more easily. ● By providing a simple user interface for copy pasting data, you can fetch data from one source, copy it, change your URL and post the data to another source. Creating REST Clients
  • 12. Rest Client in mule ● Step1: Create a rest service - this rest service should be available for consuming it ● Step2:Consume the created rest service by creating a rest client - write a java class for creating a rest client. - using invoke you can call the rest client created. Dynamic Endpoints: ● An outbound endpoint can also be dynamic. This means that the endpoint’s URI is the value of an expression, which is evaluated just before a message is sent to it. ● This allows the target of a message to be determined by its contents or the value of any message property.
  • 13. Dynamic endpoints can use either of the endpoint formats shown above. ● <outbound-endpoint address="smtp://user:secret@#[message.outboundProperties['h ost']]"/> ● <jms:outbound-endpoint host="localhost" queue="#[app.registry['defaultJmsQueue']]"/>