SlideShare ist ein Scribd-Unternehmen logo
1 von 24
RESTful
Webservices
Mohammed Luqman Shareef
Agenda
• Introduction to Webservices
• SOAP based webservices
• RESTful webservices
• Implementation of RESTful webservices
• SOAP vs. REST
• Why SOAP?
• Why REST?
• Q&A
9/29/2013www.luqmanshareef.com
2
What is a webservice?
• There are too many definitions.
• Most of them are very specific to SOAP based services, and consider
WSDL and UDDI as its integral parts, like
▫ “Web service is a standard way of integrating Web-based applications
using the XML, SOAP, WSDL and UDDI open standards over an Internet
protocol backbone. ”
• There are too generic definitions as well, like
▫ “Web services are loosely coupled computing services that can reduce
the complexity of building business applications, save costs, and enable
new business models. Services running on an arbitrary machine can be
accessed in a platform- and language-independent fashion.”
▫ “Web Services can convert your applications into Web-applications.
Web Services are published, found, and used through the Web.”
9/29/2013www.luqmanshareef.com
3
XML (eXtensible Markup Language)
A uniform data representation and exchange
mechanism
SOAP (Simple Object Access Protocol)
Lightweight (XML-based) protocol for exchange
of information in a decentralized, distributed
environment
WSDL (Web Service Description Language)
XML format that describes the web service
UDDI (Universal Description Discovery and Integration)
Like yellow pages of Web services
2010-02-08www.luqmanshareef.com
4
Components of a SOAP based web service
Lets take a scenario
• An inventory database of a Supply chain management system
gets updated with products’ information from various
vendors.
• What is the best way to communicate?
▫ Each Vendor exposes a webservice (say SOAP based).
▫ Each webservice has its own contract(WSDL) defined, consisting
of various operations, input and output message types, bindings
etc.
▫ The consumer application needs to understand the contracts,
create a client stub to communicate with each vendor. For every
new vendor a separate stub is needed.
9/29/2013www.luqmanshareef.com
5
SOAP based webservice
• Each Vendor shall expose a webservice through an end point like
http://www.vendorX.com/the-endpoint
▫ Operations can be:
 GetProduct
 AddProduct
 DeleteProduct
• For Example GetProduct message will look like
9/29/2013www.luqmanshareef.com
6
HTTP Header
SOAP Envelope
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body>
<v:GetProduct xmlns:v="http://vendorX.com/">
<v:ProdId>X123</v:ProdId>
<v:Name>Hard Drive</v:Name>
</v:GetProduct>
</env:Body>
</env:Envelope>
SOAP based webservice
• Whether it is a pull operation or a push, (i.e., request for
the product info, or add a new product) it is simply a
get/post. And the content shared is always the product
information in a standard format.
• Why do we need different contracts from different
vendors?
• Can’t we use any of the standards prevailing in the
industry to make life easier?
• Why not a simple GET operation be done with HTTP
GET method?
9/29/2013www.luqmanshareef.com
7
HTTP Protocol
• Lets use standard HTTP protocol.
• It can be accessed via a URL (Uniform Resource Locator) like
▫ http://www.vendorx.com/products/x123
• It has standard methods to
▫ Retrieve ( GET )
▫ Create ( POST )
▫ Update ( PUT )
▫ Delete (DELETE )
• Payload can be directly added to http message. No need to
wrap it in another protocol.
9/29/2013www.luqmanshareef.com
8
RESTful web services
• It is a simple stateless architecture that generally runs over HTTP.
• The focus is on a resource in the system
▫ Ex: an Employee, an Account, a Product etc.
• Each unique URL is a representation of some object
Ex : http://www.vendorx.com/products
http://www.vendorx.com/products/x123
• HTTP methods (GET/POST/…) operates on the resource.
• Object state is transferred and stored at client.
• Representation of the resource state in XML, JSON etc.
9/29/2013www.luqmanshareef.com
REpresentational State Transfer
9
RPC vs REST
• Every object has its own unique methods
• Methods can be remotely invoked over the Internet
• A single URI represents the end-point, and that's the
only contract with the Web
• Data hidden behind method calls and parameters
• Data is unavailable to Web applications
9/29/2013www.luqmanshareef.com
 Every useful data object has an address
 Resources themselves are the targets for
method calls
 The list of methods is fixed for all resources
RPC
REST
10
RESTful web services contd…
9/29/2013www.luqmanshareef.com
Client side
> Easy to experiment in browser
> Broad programming language support
> Choice of data formats
> bookmarkable
Server side
> Uniform Interface
> Cacheable
> Scalable
> Easy failover
Benefits
> Resource identification through URI
> Uniform interface
GET/PUT/POST/DELETE
> Self-descriptive messages
> Stateless interactions through hyperlinks
Principles
11
Six characteristics of REST:
• Uniform interface
• Decoupled client-server interaction
• Stateless
• Cacheable
• Layered
• Extensible through code on demand (optional)
* Services that do not conform to the above required contstraints are not strictly
RESTful web services.
9/29/2013www.luqmanshareef.com
12
Product service as RESTful
9/29/2013
www.luqmanshareef.com
Request
GET /products/X123 HTTP/1.1
Host: vendorx.com
Accept: application/xml
Response
HTTP/1.1 200 OK
Date: Tue, 09 Feb 2010 11:41:20 GMT
Server: Apache/1.3.6
Content-Type: application/xml; charset=UTF-8
<?xml version="1.0"?>
<Products xmlns="…">
<Product id=“X123”>
…
</Product>
</Products>
Method Resource
Representation
State
transfer
13
Developing a RESTful web service
using JAX-RS
9/29/2013www.luqmanshareef.com
package com.vendorx.products;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;
@Path("/employees/{pid}")
public class Product{
@GET
@Produces("text/xml")
public String getProduct(@PathParam(“pid") String pId) {
...
…
}
}
14
JAX-RS REST Annotations
Annotation Description
@Path
The @Path annotation's value is a relative URI path indicating where the Java class will be hosted, for
example, /helloworld. You can also embed variables in the URIs to make a URI path template. For
example, you could ask for the name of a user, and pass it to the application as a variable in the URI, like
this, /helloworld/{username}.
@GET The @GET annotation is a request method designator and corresponds to the similarly named HTTP
method. The Java method annotated with this request method designator will process HTTP GET
requests. The behavior of a resource is determined by the HTTP method to which the resource is
responding.
@POST The @POST annotation is a request method designator and corresponds to the similarly named HTTP
method. The Java method annotated with this request method designator will process HTTP POST
requests. The behavior of a resource is determined by the HTTP method to which the resource is
responding.
@PUT The @PUT annotation is a request method designator and corresponds to the similarly named HTTP
method. The Java method annotated with this request method designator will process HTTP PUT requests.
The behavior of a resource is determined by the HTTP method to which the resource is responding.
@DELETE The @DELETE annotation is a request method designator and corresponds to the similarly named HTTP
method. The Java method annotated with this request method designator will process HTTPDELETE
requests. The behavior of a resource is determined by the HTTP method to which the resource is
responding.
9/29/2013www.luqmanshareef.com
15
JAX-RS REST Annotations
Annotation Description
@HEAD
The @HEAD annotation is a request method designator and corresponds to the similarly named
HTTP method. The Java method annotated with this request method designator will process HTTP
HEAD requests. The behavior of a resource is determined by the HTTP method to which the
resource is responding.
@PathParam
The @PathParam annotation is a type of parameter that you can extract for use in your resource
class. URI path parameters are extracted from the request URI, and the parameter names
correspond to the URI path template variable names specified in the @Path class-level annotation.
@QueryParam The @QueryParam annotation is a type of parameter that you can extract for use in your resource
class. Query parameters are extracted from the request URI query parameters.
@Consumes The @Consumes annotation is used to specify the MIME media types of representations a resource
can consume that were sent by the client.
@Produces The @Produces annotation is used to specify the MIME media types of representations a resource
can produce and send back to the client, for example, "text/plain".
9/29/2013www.luqmanshareef.com
16
Using Spring framework
9/29/2013www.luqmanshareef.com
17
Arguments: SOAP vs. REST
• SOAP based webservices are too complex for a
web based service.
• How about transactions and reliability in REST?
• SOAP based webservices are protocol
independent.
• REST operations are limited (only http methods)
• SOAP has built-in error handling.
• REST is easy to test (in any browser)
• SOAP is not only for Web.
• REST development is faster and easier.
9/29/2013www.luqmanshareef.com
18
Arguments: SOAP vs. REST
• REST has better performance and scalability.
• SOAP has many extensions built WS-* (security,
transaction etc.)
• A service offered in a REST style will be easier to
consume than some complex API:
▫ Lower learning curve for the consumer
▫ Lower support overhead for the producer
• What happens when you need application semantics that
don't fit into the GET / PUT / POST / DELETE generic
interfaces and representational state model?
• These interfaces are sufficiently general. Other interfaces
considered harmful because they increase the costs of
consuming particular services
9/29/2013www.luqmanshareef.com
19
Why REST?
• Exposing a public API over the internet to handle CRUD operations on data.
• REST permits many different formats like XML, JSON etc.
• REST reads can be cached.
• REST is concise. No need of additional messaging layer.
• REST is stateless. If an operation needs to be continued just REST doesn’t help.
• Easy to test (in any browser, no need of a new client to write)
• REST is particularly useful for restricted-profile devices such as mobile and PDAs for
which the overhead of additional parameters like headers and other SOAP elements
are less.
9/29/2013www.luqmanshareef.com
20
Why SOAP?
• SOAP is not only for Web. It has its own protocol.
• SOAP Exposes application logic (not data) as service. Exposes named operations.
• Can implement stateful web services.
• SOAP Web services are useful in handling asynchronous processing and invocation.
• SOAP has additional feature built on top of it which REST doesn’t.
▫ WS-Security
▫ WS-Reliable Messaging
▫ WS-Atomic Transactions
• Most real-world applications are not simple and support complex operations, which
require conversational state and contextual information to be maintained. With the SOAP
approach, developers need not worry about writing this plumbing code into the application
layer themselves.
9/29/2013www.luqmanshareef.com
21
WSDL 2.0
• WSDL 2.0 is tailored for SOAP-based Web services
• However, HTTP binding in WSDL 2.0 allows for good description of HTTP services
▫ <binding name="HttpBinding" interface="m:GetTemperature"
type="http://www.w3.org/2005/08/wsdl/http">
<operation ref="m:location" whttp:method="GET"
whttp:location="{country}/{city}"/>
</binding>
• It allows for an HTTP GET on http://weather.example/country/city:
▫ HTTP/1.1 200 Here's the temperature for you
Content-Type: application/xml
…
<weather xmlns="…">
<temperature>23</temperature>
</weather>
• All HTTP methods are supported.
9/29/2013www.luqmanshareef.com
22
2010-02-08www.luqmanshareef.com
23
Questions?
2010-02-08www.luqmanshareef.com
24

Weitere ähnliche Inhalte

Was ist angesagt?

Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical ApproachMadhaiyan Muthu
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
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 APIPankaj Bajaj
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)Jef Claes
 
Designing REST services with Spring MVC
Designing REST services with Spring MVCDesigning REST services with Spring MVC
Designing REST services with Spring MVCSerhii Kartashov
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraintInviqa
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsIdo Flatow
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigMandakini Kumari
 

Was ist angesagt? (20)

SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical Approach
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
REST API Design
REST API DesignREST API Design
REST API Design
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
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
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)
 
Designing REST services with Spring MVC
Designing REST services with Spring MVCDesigning REST services with Spring MVC
Designing REST services with Spring MVC
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Excellent rest using asp.net web api
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web api
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGig
 

Andere mochten auch

Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservicesMohammed A. Imran
 
Fnul selling techniques and handling objection
Fnul selling techniques and handling objectionFnul selling techniques and handling objection
Fnul selling techniques and handling objectionPik Lertsavetpong
 
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...Luca Spoldi
 
Treb Market Watch August 2010
Treb Market Watch August 2010Treb Market Watch August 2010
Treb Market Watch August 2010James Metcalfe
 
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014Social Monitor keynote - Barcelona Affiliate Conference #BAC2014
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014Joakim Nilsson
 
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...Mamadigital
 
Caruso Inq Project
Caruso Inq ProjectCaruso Inq Project
Caruso Inq Projectkalmanidisn1
 
MedicinMan vol1 Issue 4; November 2011
MedicinMan vol1 Issue 4; November 2011MedicinMan vol1 Issue 4; November 2011
MedicinMan vol1 Issue 4; November 2011Anup Soans
 
Week13 - Group Presentation Slide
Week13 - Group Presentation SlideWeek13 - Group Presentation Slide
Week13 - Group Presentation Slidetykl94
 
การปรับปร..
การปรับปร..การปรับปร..
การปรับปร..guestd6bdc29e4
 
Pharma Field Sales Learning and Development
Pharma Field Sales Learning and DevelopmentPharma Field Sales Learning and Development
Pharma Field Sales Learning and DevelopmentAnup Soans
 
Ccm Smim2l
Ccm Smim2lCcm Smim2l
Ccm Smim2lMIMCCMS
 
Pegasus essentials 2012 2013
Pegasus essentials 2012 2013Pegasus essentials 2012 2013
Pegasus essentials 2012 2013Jennifer Marten
 
MedicinMan October 2012
MedicinMan  October 2012MedicinMan  October 2012
MedicinMan October 2012Anup Soans
 
Data Science in Cardiac Sciences
Data Science in Cardiac SciencesData Science in Cardiac Sciences
Data Science in Cardiac SciencesRobert Chen
 
Camus, Albert Ciuma Uc
Camus, Albert   Ciuma UcCamus, Albert   Ciuma Uc
Camus, Albert Ciuma Ucruoy
 
2009 Elvis Presley 50s Movie Collection
2009   Elvis Presley   50s Movie Collection2009   Elvis Presley   50s Movie Collection
2009 Elvis Presley 50s Movie CollectionElvis Presley Blues
 
四驱赛车
四驱赛车四驱赛车
四驱赛车zust
 

Andere mochten auch (20)

Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservices
 
Fnul selling techniques and handling objection
Fnul selling techniques and handling objectionFnul selling techniques and handling objection
Fnul selling techniques and handling objection
 
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...
Sentieri Digitali 2010 - La comunicazione nell'era delle realtà virtuali (by ...
 
Treb Market Watch August 2010
Treb Market Watch August 2010Treb Market Watch August 2010
Treb Market Watch August 2010
 
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014Social Monitor keynote - Barcelona Affiliate Conference #BAC2014
Social Monitor keynote - Barcelona Affiliate Conference #BAC2014
 
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...
Comunicare con i Motori di Ricerca senza essere fraintesi: alla scoperta del ...
 
Caruso Inq Project
Caruso Inq ProjectCaruso Inq Project
Caruso Inq Project
 
MedicinMan vol1 Issue 4; November 2011
MedicinMan vol1 Issue 4; November 2011MedicinMan vol1 Issue 4; November 2011
MedicinMan vol1 Issue 4; November 2011
 
Week13 - Group Presentation Slide
Week13 - Group Presentation SlideWeek13 - Group Presentation Slide
Week13 - Group Presentation Slide
 
การปรับปร..
การปรับปร..การปรับปร..
การปรับปร..
 
Pharma Field Sales Learning and Development
Pharma Field Sales Learning and DevelopmentPharma Field Sales Learning and Development
Pharma Field Sales Learning and Development
 
Ccm Smim2l
Ccm Smim2lCcm Smim2l
Ccm Smim2l
 
Pegasus essentials 2012 2013
Pegasus essentials 2012 2013Pegasus essentials 2012 2013
Pegasus essentials 2012 2013
 
MedicinMan October 2012
MedicinMan  October 2012MedicinMan  October 2012
MedicinMan October 2012
 
Tarea
TareaTarea
Tarea
 
Data Science in Cardiac Sciences
Data Science in Cardiac SciencesData Science in Cardiac Sciences
Data Science in Cardiac Sciences
 
Camus, Albert Ciuma Uc
Camus, Albert   Ciuma UcCamus, Albert   Ciuma Uc
Camus, Albert Ciuma Uc
 
Sales Management
Sales ManagementSales Management
Sales Management
 
2009 Elvis Presley 50s Movie Collection
2009   Elvis Presley   50s Movie Collection2009   Elvis Presley   50s Movie Collection
2009 Elvis Presley 50s Movie Collection
 
四驱赛车
四驱赛车四驱赛车
四驱赛车
 

Ähnlich wie Restful webservices

Ähnlich wie Restful webservices (20)

REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Restful web services
Restful web servicesRestful web services
Restful web services
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
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 Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.ppt
 
Application_layer.pdf
Application_layer.pdfApplication_layer.pdf
Application_layer.pdf
 
Web service architecture
Web service architectureWeb service architecture
Web service architecture
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
Web technology-guide
Web technology-guideWeb technology-guide
Web technology-guide
 
Innovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesInnovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open Interfaces
 
Web service Introduction
Web service IntroductionWeb service Introduction
Web service Introduction
 
Microservices
MicroservicesMicroservices
Microservices
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
 
Ch-1_.ppt
Ch-1_.pptCh-1_.ppt
Ch-1_.ppt
 
introduction to Web system
introduction to Web systemintroduction to Web system
introduction to Web system
 
REST Presentation
REST PresentationREST Presentation
REST Presentation
 

Mehr von Luqman Shareef

Mehr von Luqman Shareef (10)

Containers virtaulization and docker
Containers virtaulization and dockerContainers virtaulization and docker
Containers virtaulization and docker
 
Scrum luqman
Scrum luqmanScrum luqman
Scrum luqman
 
Cloud computing by Luqman
Cloud computing by LuqmanCloud computing by Luqman
Cloud computing by Luqman
 
Tech Days 2010
Tech  Days 2010Tech  Days 2010
Tech Days 2010
 
Ajax
AjaxAjax
Ajax
 
Service Oriented Architecture Luqman
Service Oriented Architecture LuqmanService Oriented Architecture Luqman
Service Oriented Architecture Luqman
 
Xml by Luqman
Xml by LuqmanXml by Luqman
Xml by Luqman
 
Web Service Security
Web Service SecurityWeb Service Security
Web Service Security
 
Service Oriented Architecture
Service Oriented ArchitectureService Oriented Architecture
Service Oriented Architecture
 
J2SE 5
J2SE 5J2SE 5
J2SE 5
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Restful webservices

  • 2. Agenda • Introduction to Webservices • SOAP based webservices • RESTful webservices • Implementation of RESTful webservices • SOAP vs. REST • Why SOAP? • Why REST? • Q&A 9/29/2013www.luqmanshareef.com 2
  • 3. What is a webservice? • There are too many definitions. • Most of them are very specific to SOAP based services, and consider WSDL and UDDI as its integral parts, like ▫ “Web service is a standard way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. ” • There are too generic definitions as well, like ▫ “Web services are loosely coupled computing services that can reduce the complexity of building business applications, save costs, and enable new business models. Services running on an arbitrary machine can be accessed in a platform- and language-independent fashion.” ▫ “Web Services can convert your applications into Web-applications. Web Services are published, found, and used through the Web.” 9/29/2013www.luqmanshareef.com 3
  • 4. XML (eXtensible Markup Language) A uniform data representation and exchange mechanism SOAP (Simple Object Access Protocol) Lightweight (XML-based) protocol for exchange of information in a decentralized, distributed environment WSDL (Web Service Description Language) XML format that describes the web service UDDI (Universal Description Discovery and Integration) Like yellow pages of Web services 2010-02-08www.luqmanshareef.com 4 Components of a SOAP based web service
  • 5. Lets take a scenario • An inventory database of a Supply chain management system gets updated with products’ information from various vendors. • What is the best way to communicate? ▫ Each Vendor exposes a webservice (say SOAP based). ▫ Each webservice has its own contract(WSDL) defined, consisting of various operations, input and output message types, bindings etc. ▫ The consumer application needs to understand the contracts, create a client stub to communicate with each vendor. For every new vendor a separate stub is needed. 9/29/2013www.luqmanshareef.com 5
  • 6. SOAP based webservice • Each Vendor shall expose a webservice through an end point like http://www.vendorX.com/the-endpoint ▫ Operations can be:  GetProduct  AddProduct  DeleteProduct • For Example GetProduct message will look like 9/29/2013www.luqmanshareef.com 6 HTTP Header SOAP Envelope <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> <env:Body> <v:GetProduct xmlns:v="http://vendorX.com/"> <v:ProdId>X123</v:ProdId> <v:Name>Hard Drive</v:Name> </v:GetProduct> </env:Body> </env:Envelope>
  • 7. SOAP based webservice • Whether it is a pull operation or a push, (i.e., request for the product info, or add a new product) it is simply a get/post. And the content shared is always the product information in a standard format. • Why do we need different contracts from different vendors? • Can’t we use any of the standards prevailing in the industry to make life easier? • Why not a simple GET operation be done with HTTP GET method? 9/29/2013www.luqmanshareef.com 7
  • 8. HTTP Protocol • Lets use standard HTTP protocol. • It can be accessed via a URL (Uniform Resource Locator) like ▫ http://www.vendorx.com/products/x123 • It has standard methods to ▫ Retrieve ( GET ) ▫ Create ( POST ) ▫ Update ( PUT ) ▫ Delete (DELETE ) • Payload can be directly added to http message. No need to wrap it in another protocol. 9/29/2013www.luqmanshareef.com 8
  • 9. RESTful web services • It is a simple stateless architecture that generally runs over HTTP. • The focus is on a resource in the system ▫ Ex: an Employee, an Account, a Product etc. • Each unique URL is a representation of some object Ex : http://www.vendorx.com/products http://www.vendorx.com/products/x123 • HTTP methods (GET/POST/…) operates on the resource. • Object state is transferred and stored at client. • Representation of the resource state in XML, JSON etc. 9/29/2013www.luqmanshareef.com REpresentational State Transfer 9
  • 10. RPC vs REST • Every object has its own unique methods • Methods can be remotely invoked over the Internet • A single URI represents the end-point, and that's the only contract with the Web • Data hidden behind method calls and parameters • Data is unavailable to Web applications 9/29/2013www.luqmanshareef.com  Every useful data object has an address  Resources themselves are the targets for method calls  The list of methods is fixed for all resources RPC REST 10
  • 11. RESTful web services contd… 9/29/2013www.luqmanshareef.com Client side > Easy to experiment in browser > Broad programming language support > Choice of data formats > bookmarkable Server side > Uniform Interface > Cacheable > Scalable > Easy failover Benefits > Resource identification through URI > Uniform interface GET/PUT/POST/DELETE > Self-descriptive messages > Stateless interactions through hyperlinks Principles 11
  • 12. Six characteristics of REST: • Uniform interface • Decoupled client-server interaction • Stateless • Cacheable • Layered • Extensible through code on demand (optional) * Services that do not conform to the above required contstraints are not strictly RESTful web services. 9/29/2013www.luqmanshareef.com 12
  • 13. Product service as RESTful 9/29/2013 www.luqmanshareef.com Request GET /products/X123 HTTP/1.1 Host: vendorx.com Accept: application/xml Response HTTP/1.1 200 OK Date: Tue, 09 Feb 2010 11:41:20 GMT Server: Apache/1.3.6 Content-Type: application/xml; charset=UTF-8 <?xml version="1.0"?> <Products xmlns="…"> <Product id=“X123”> … </Product> </Products> Method Resource Representation State transfer 13
  • 14. Developing a RESTful web service using JAX-RS 9/29/2013www.luqmanshareef.com package com.vendorx.products; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.ws.rs.Path; @Path("/employees/{pid}") public class Product{ @GET @Produces("text/xml") public String getProduct(@PathParam(“pid") String pId) { ... … } } 14
  • 15. JAX-RS REST Annotations Annotation Description @Path The @Path annotation's value is a relative URI path indicating where the Java class will be hosted, for example, /helloworld. You can also embed variables in the URIs to make a URI path template. For example, you could ask for the name of a user, and pass it to the application as a variable in the URI, like this, /helloworld/{username}. @GET The @GET annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP GET requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. @POST The @POST annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP POST requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. @PUT The @PUT annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP PUT requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. @DELETE The @DELETE annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTPDELETE requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. 9/29/2013www.luqmanshareef.com 15
  • 16. JAX-RS REST Annotations Annotation Description @HEAD The @HEAD annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP HEAD requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. @PathParam The @PathParam annotation is a type of parameter that you can extract for use in your resource class. URI path parameters are extracted from the request URI, and the parameter names correspond to the URI path template variable names specified in the @Path class-level annotation. @QueryParam The @QueryParam annotation is a type of parameter that you can extract for use in your resource class. Query parameters are extracted from the request URI query parameters. @Consumes The @Consumes annotation is used to specify the MIME media types of representations a resource can consume that were sent by the client. @Produces The @Produces annotation is used to specify the MIME media types of representations a resource can produce and send back to the client, for example, "text/plain". 9/29/2013www.luqmanshareef.com 16
  • 18. Arguments: SOAP vs. REST • SOAP based webservices are too complex for a web based service. • How about transactions and reliability in REST? • SOAP based webservices are protocol independent. • REST operations are limited (only http methods) • SOAP has built-in error handling. • REST is easy to test (in any browser) • SOAP is not only for Web. • REST development is faster and easier. 9/29/2013www.luqmanshareef.com 18
  • 19. Arguments: SOAP vs. REST • REST has better performance and scalability. • SOAP has many extensions built WS-* (security, transaction etc.) • A service offered in a REST style will be easier to consume than some complex API: ▫ Lower learning curve for the consumer ▫ Lower support overhead for the producer • What happens when you need application semantics that don't fit into the GET / PUT / POST / DELETE generic interfaces and representational state model? • These interfaces are sufficiently general. Other interfaces considered harmful because they increase the costs of consuming particular services 9/29/2013www.luqmanshareef.com 19
  • 20. Why REST? • Exposing a public API over the internet to handle CRUD operations on data. • REST permits many different formats like XML, JSON etc. • REST reads can be cached. • REST is concise. No need of additional messaging layer. • REST is stateless. If an operation needs to be continued just REST doesn’t help. • Easy to test (in any browser, no need of a new client to write) • REST is particularly useful for restricted-profile devices such as mobile and PDAs for which the overhead of additional parameters like headers and other SOAP elements are less. 9/29/2013www.luqmanshareef.com 20
  • 21. Why SOAP? • SOAP is not only for Web. It has its own protocol. • SOAP Exposes application logic (not data) as service. Exposes named operations. • Can implement stateful web services. • SOAP Web services are useful in handling asynchronous processing and invocation. • SOAP has additional feature built on top of it which REST doesn’t. ▫ WS-Security ▫ WS-Reliable Messaging ▫ WS-Atomic Transactions • Most real-world applications are not simple and support complex operations, which require conversational state and contextual information to be maintained. With the SOAP approach, developers need not worry about writing this plumbing code into the application layer themselves. 9/29/2013www.luqmanshareef.com 21
  • 22. WSDL 2.0 • WSDL 2.0 is tailored for SOAP-based Web services • However, HTTP binding in WSDL 2.0 allows for good description of HTTP services ▫ <binding name="HttpBinding" interface="m:GetTemperature" type="http://www.w3.org/2005/08/wsdl/http"> <operation ref="m:location" whttp:method="GET" whttp:location="{country}/{city}"/> </binding> • It allows for an HTTP GET on http://weather.example/country/city: ▫ HTTP/1.1 200 Here's the temperature for you Content-Type: application/xml … <weather xmlns="…"> <temperature>23</temperature> </weather> • All HTTP methods are supported. 9/29/2013www.luqmanshareef.com 22