SlideShare a Scribd company logo
How to use REST Component
15-12-2014
Abstract
• The main motto of this PPT is How to use REST
Component in our applications.
Introduction
• REST stands for Representational State
Transfer. REST exposes a much simpler
interface than SOAP. REST components are
bound with HTTP. So, if you are designing
an application to be used exclusively on the
Web, REST is a very good option. RESTful
applications simply rely on the built-in HTTP
security. A REST design is good for database-
driven applications and also when a client
wants quick integration.
SOAP Component POC:
Link: https://youtu.be/h-aJIjt9TcQ
How to do above POC using REST component?
Example
ArthematicOperations
a. Addition
b. Subtraction
c. Multiplication
.mflow
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd">
<flow name="RestComponentFlow1" doc:name="RestComponentFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8098" doc:name="HTTP"/>
<logger message="---Entered into the flow" level="INFO" doc:name="Logger"/>
<jersey:resources doc:name="REST">
<component class="com.ArthematicOperations"/>
</jersey:resources>
</flow>
</mule>
com.ArthematicOperations:
• package com;
• import javax.ws.rs.Consumes;
• import javax.ws.rs.POST;
• import javax.ws.rs.Path;
• import javax.ws.rs.Produces;
• import javax.ws.rs.core.MediaType;
• import org.codehaus.jackson.JsonNode;
• import org.codehaus.jettison.json.JSONObject;
• @Path("/")
• public class ArthematicOperations {
• @POST
• @Produces(MediaType.APPLICATION_JSON)
• @Consumes(MediaType.APPLICATION_JSON)
• @Path("Addition")
• public Object addition(JsonNode inputJSON) throws Exception {
• JSONObject jsonStatus = new JSONObject();
• jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())+Integer.parseInt(inputJSON.get("Num2").getTextValue())));
• return jsonStatus.toString();
• }
• @POST
• @Consumes(MediaType.APPLICATION_JSON)
• @Produces(MediaType.APPLICATION_JSON)
• @Path("Subtraction")
• public Object subtraction(JsonNode inputJSON) throws Exception {JSONObject jsonStatus = new JSONObject();
• jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())-Integer.parseInt(inputJSON.get("Num2").getTextValue())));
• return jsonStatus.toString();
• }
• @POST
• @Consumes(MediaType.APPLICATION_JSON)
• @Produces(MediaType.APPLICATION_JSON)
• @Path("Multiplication")
• public Object multiplication(JsonNode inputJSON) throws Exception {JSONObject jsonStatus = new JSONObject();
• jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())*Integer.parseInt(inputJSON.get("Num2").getTextValue())));
• return jsonStatus.toString();
• }
• }
How to test this?
URLs
Addition: http://localhost:8098/Addition
Subtraction: http://localhost:8098/Subtraction
Multiplication:
http://localhost:8098/Multiplication
Trigger the methods:
1. Addition:
• Console:
INFO 2015-12-15 18:09:29,554 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Application: RestComponent *
* OS encoding: Cp1252, Mule encoding: UTF-8 *
* *
* Agents Running: *
* Clustering Agent *
* JMX Agent *
**********************************************************************
INFO 2015-12-15 18:09:29,556 [main]
org.mule.module.launcher.MuleDeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'RestComponent' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2015-12-15 18:10:28,825
[[RestComponent].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: ---Entered into the flow
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.7/rest-component-reference

More Related Content

What's hot

Basic example using until successful component
Basic example using until successful componentBasic example using until successful component
Basic example using until successful component
prudhvivreddy
 
ITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul Services
Ortus Solutions, Corp
 
Migrando una app de angular.js a Blazor
Migrando una app de angular.js a BlazorMigrando una app de angular.js a Blazor
Migrando una app de angular.js a Blazor
Miguel Angel Teheran Garcia
 
Mule soap
Mule soapMule soap
Mule soap
D.Rajesh Kumar
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
himajareddys
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
Praneethchampion
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
bmani
 

What's hot (7)

Basic example using until successful component
Basic example using until successful componentBasic example using until successful component
Basic example using until successful component
 
ITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul Services
 
Migrando una app de angular.js a Blazor
Migrando una app de angular.js a BlazorMigrando una app de angular.js a Blazor
Migrando una app de angular.js a Blazor
 
Mule soap
Mule soapMule soap
Mule soap
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 

Viewers also liked

Similar product analysis
Similar product analysisSimilar product analysis
Similar product analysis
bentrant
 
1.3 blog
1.3 blog1.3 blog
NFPtweetup 8: RAFBF 1940 chronicle presentation
NFPtweetup 8: RAFBF 1940 chronicle presentationNFPtweetup 8: RAFBF 1940 chronicle presentation
NFPtweetup 8: RAFBF 1940 chronicle presentationNFPtweetup
 
Embedded training
Embedded trainingEmbedded training
Embedded training
sowmiya437
 
Using Intergenerational Approaches for Digital Inclusion
 Using Intergenerational Approaches for Digital Inclusion Using Intergenerational Approaches for Digital Inclusion
Using Intergenerational Approaches for Digital Inclusion
Generations Working Together
 
Question 2 - How effective is the combination of your main product and ancill...
Question 2 - How effective is the combination of your main product and ancill...Question 2 - How effective is the combination of your main product and ancill...
Question 2 - How effective is the combination of your main product and ancill...
bentrant
 
Home remedies for burping (belching)
Home remedies for burping (belching)Home remedies for burping (belching)
Home remedies for burping (belching)
Happiness Goodhead
 
Arteonline bcn emma
Arteonline bcn emmaArteonline bcn emma
Arteonline bcn emma
TheArtMarket
 
Lavacow presentation
Lavacow presentationLavacow presentation
Lavacow presentation
TheArtMarket
 
Te amo
Te amoTe amo
Te amo
Denis Cabral
 
Age Awareness
Age AwarenessAge Awareness
Age Awareness
Alison Clyde
 
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
TemboStatus
 
Bosch, Jaipur
Bosch, JaipurBosch, Jaipur
Bosch, Jaipur
India Water Portal
 

Viewers also liked (15)

Similar product analysis
Similar product analysisSimilar product analysis
Similar product analysis
 
1.3 blog
1.3 blog1.3 blog
1.3 blog
 
NFPtweetup 8: RAFBF 1940 chronicle presentation
NFPtweetup 8: RAFBF 1940 chronicle presentationNFPtweetup 8: RAFBF 1940 chronicle presentation
NFPtweetup 8: RAFBF 1940 chronicle presentation
 
Embedded training
Embedded trainingEmbedded training
Embedded training
 
Using Intergenerational Approaches for Digital Inclusion
 Using Intergenerational Approaches for Digital Inclusion Using Intergenerational Approaches for Digital Inclusion
Using Intergenerational Approaches for Digital Inclusion
 
Question 2 - How effective is the combination of your main product and ancill...
Question 2 - How effective is the combination of your main product and ancill...Question 2 - How effective is the combination of your main product and ancill...
Question 2 - How effective is the combination of your main product and ancill...
 
Home remedies for burping (belching)
Home remedies for burping (belching)Home remedies for burping (belching)
Home remedies for burping (belching)
 
Desember 0002 copy
Desember  0002 copyDesember  0002 copy
Desember 0002 copy
 
Sesión 4
Sesión 4Sesión 4
Sesión 4
 
Arteonline bcn emma
Arteonline bcn emmaArteonline bcn emma
Arteonline bcn emma
 
Lavacow presentation
Lavacow presentationLavacow presentation
Lavacow presentation
 
Te amo
Te amoTe amo
Te amo
 
Age Awareness
Age AwarenessAge Awareness
Age Awareness
 
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
#TorontoHR - How to achieve continuous feedback that drives results - Priya B...
 
Bosch, Jaipur
Bosch, JaipurBosch, Jaipur
Bosch, Jaipur
 

Similar to How to use rest component

REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)
Sascha Wenninger
 
RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel Mardjan
Jexia
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
Christian Guenther
 
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from TechlightningFrequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
Arul ChristhuRaj Alphonse
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
rainynovember12
 
REST - What's It All About? (SAP TechEd 2012, CD110)
REST - What's It All About? (SAP TechEd 2012, CD110)REST - What's It All About? (SAP TechEd 2012, CD110)
REST - What's It All About? (SAP TechEd 2012, CD110)Sascha Wenninger
 
Hia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economyHia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economy
Andrew Coleman
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
Nicola Pedot
 
Introducing the Hub for Data Orchestration
Introducing the Hub for Data OrchestrationIntroducing the Hub for Data Orchestration
Introducing the Hub for Data Orchestration
Alluxio, Inc.
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
Aparna Sharma
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
Aparna Sharma
 
Rest applied
Rest appliedRest applied
Rest applied
Murilo Beltrame
 
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
Royston Lobo
 
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Stephane Beladaci
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
tom_li
 
Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbook
Katy Slemon
 
Checklist for progressive web app development
Checklist for progressive web app developmentChecklist for progressive web app development
Checklist for progressive web app development
WebGuru Infosystems Pvt. Ltd.
 
Web Application Development using PHP and MySQL
Web Application Development using PHP and MySQLWeb Application Development using PHP and MySQL
Web Application Development using PHP and MySQLGanesh Kamath
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
Pankaj Bajaj
 

Similar to How to use rest component (20)

REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)
 
RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel Mardjan
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
 
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from TechlightningFrequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
REST - What's It All About? (SAP TechEd 2012, CD110)
REST - What's It All About? (SAP TechEd 2012, CD110)REST - What's It All About? (SAP TechEd 2012, CD110)
REST - What's It All About? (SAP TechEd 2012, CD110)
 
Hia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economyHia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economy
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Introducing the Hub for Data Orchestration
Introducing the Hub for Data OrchestrationIntroducing the Hub for Data Orchestration
Introducing the Hub for Data Orchestration
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 
Rest applied
Rest appliedRest applied
Rest applied
 
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
 
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
Talking to 25% of the web - In-depth report and analysis on the WordPress RES...
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
 
Rest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbookRest api best practices – comprehensive handbook
Rest api best practices – comprehensive handbook
 
Checklist for progressive web app development
Checklist for progressive web app developmentChecklist for progressive web app development
Checklist for progressive web app development
 
Web Application Development using PHP and MySQL
Web Application Development using PHP and MySQLWeb Application Development using PHP and MySQL
Web Application Development using PHP and MySQL
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 

More from RaviRajuRamaKrishna

Mock component in munit
Mock component in munitMock component in munit
Mock component in munit
RaviRajuRamaKrishna
 
Jms selector
Jms selectorJms selector
Jms selector
RaviRajuRamaKrishna
 
Sftplite
SftpliteSftplite
Object store
Object storeObject store
Object store
RaviRajuRamaKrishna
 
How to use splitter component
How to use splitter componentHow to use splitter component
How to use splitter component
RaviRajuRamaKrishna
 
How to use soap component
How to use soap componentHow to use soap component
How to use soap component
RaviRajuRamaKrishna
 
How to use salesforce cloud connector
How to use salesforce cloud connectorHow to use salesforce cloud connector
How to use salesforce cloud connector
RaviRajuRamaKrishna
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
RaviRajuRamaKrishna
 
How to use wildcard filter
How to use wildcard filterHow to use wildcard filter
How to use wildcard filter
RaviRajuRamaKrishna
 
How to use not filter
How to use not filterHow to use not filter
How to use not filter
RaviRajuRamaKrishna
 
How to use or filter
How to use or filterHow to use or filter
How to use or filter
RaviRajuRamaKrishna
 
How to use and filter
How to use and filterHow to use and filter
How to use and filter
RaviRajuRamaKrishna
 
How to use data mapper transformer
How to use data mapper transformerHow to use data mapper transformer
How to use data mapper transformer
RaviRajuRamaKrishna
 
How to use bean as datasource in database connector
How to use bean as datasource in database connectorHow to use bean as datasource in database connector
How to use bean as datasource in database connector
RaviRajuRamaKrishna
 

More from RaviRajuRamaKrishna (14)

Mock component in munit
Mock component in munitMock component in munit
Mock component in munit
 
Jms selector
Jms selectorJms selector
Jms selector
 
Sftplite
SftpliteSftplite
Sftplite
 
Object store
Object storeObject store
Object store
 
How to use splitter component
How to use splitter componentHow to use splitter component
How to use splitter component
 
How to use soap component
How to use soap componentHow to use soap component
How to use soap component
 
How to use salesforce cloud connector
How to use salesforce cloud connectorHow to use salesforce cloud connector
How to use salesforce cloud connector
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
How to use wildcard filter
How to use wildcard filterHow to use wildcard filter
How to use wildcard filter
 
How to use not filter
How to use not filterHow to use not filter
How to use not filter
 
How to use or filter
How to use or filterHow to use or filter
How to use or filter
 
How to use and filter
How to use and filterHow to use and filter
How to use and filter
 
How to use data mapper transformer
How to use data mapper transformerHow to use data mapper transformer
How to use data mapper transformer
 
How to use bean as datasource in database connector
How to use bean as datasource in database connectorHow to use bean as datasource in database connector
How to use bean as datasource in database connector
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 

How to use rest component

  • 1. How to use REST Component 15-12-2014
  • 2. Abstract • The main motto of this PPT is How to use REST Component in our applications.
  • 3. Introduction • REST stands for Representational State Transfer. REST exposes a much simpler interface than SOAP. REST components are bound with HTTP. So, if you are designing an application to be used exclusively on the Web, REST is a very good option. RESTful applications simply rely on the built-in HTTP security. A REST design is good for database- driven applications and also when a client wants quick integration.
  • 4. SOAP Component POC: Link: https://youtu.be/h-aJIjt9TcQ How to do above POC using REST component?
  • 6.
  • 7. .mflow <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd"> <flow name="RestComponentFlow1" doc:name="RestComponentFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8098" doc:name="HTTP"/> <logger message="---Entered into the flow" level="INFO" doc:name="Logger"/> <jersey:resources doc:name="REST"> <component class="com.ArthematicOperations"/> </jersey:resources> </flow> </mule>
  • 8. com.ArthematicOperations: • package com; • import javax.ws.rs.Consumes; • import javax.ws.rs.POST; • import javax.ws.rs.Path; • import javax.ws.rs.Produces; • import javax.ws.rs.core.MediaType; • import org.codehaus.jackson.JsonNode; • import org.codehaus.jettison.json.JSONObject; • @Path("/") • public class ArthematicOperations { • @POST • @Produces(MediaType.APPLICATION_JSON) • @Consumes(MediaType.APPLICATION_JSON) • @Path("Addition") • public Object addition(JsonNode inputJSON) throws Exception { • JSONObject jsonStatus = new JSONObject(); • jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())+Integer.parseInt(inputJSON.get("Num2").getTextValue()))); • return jsonStatus.toString(); • } • @POST • @Consumes(MediaType.APPLICATION_JSON) • @Produces(MediaType.APPLICATION_JSON) • @Path("Subtraction") • public Object subtraction(JsonNode inputJSON) throws Exception {JSONObject jsonStatus = new JSONObject(); • jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())-Integer.parseInt(inputJSON.get("Num2").getTextValue()))); • return jsonStatus.toString(); • } • @POST • @Consumes(MediaType.APPLICATION_JSON) • @Produces(MediaType.APPLICATION_JSON) • @Path("Multiplication") • public Object multiplication(JsonNode inputJSON) throws Exception {JSONObject jsonStatus = new JSONObject(); • jsonStatus.put("Result",(Integer.parseInt(inputJSON.get("Num1").getTextValue())*Integer.parseInt(inputJSON.get("Num2").getTextValue()))); • return jsonStatus.toString(); • } • }
  • 9. How to test this? URLs Addition: http://localhost:8098/Addition Subtraction: http://localhost:8098/Subtraction Multiplication: http://localhost:8098/Multiplication
  • 11. • Console: INFO 2015-12-15 18:09:29,554 [main] org.mule.DefaultMuleContext: ********************************************************************** * Application: RestComponent * * OS encoding: Cp1252, Mule encoding: UTF-8 * * * * Agents Running: * * Clustering Agent * * JMX Agent * ********************************************************************** INFO 2015-12-15 18:09:29,556 [main] org.mule.module.launcher.MuleDeploymentService: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Started app 'RestComponent' + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INFO 2015-12-15 18:10:28,825 [[RestComponent].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: ---Entered into the flow