SlideShare une entreprise Scribd logo
1  sur  24
Web Services

 The SOAP
     &
 The REST

               Edison Lascano
Web Services
Web Services: Method of communication for
web applications (Internet, intranet, extranet,
desktop, mobile) .
   Application layer :
     Mainly the HTTP protocol and port 80.
     Port and protocol may change, e.g.
     SMTP
   Message Formats:
     XML, JSON, RSS, longer than binary.
   MIME types match resource
representations.
JSON / XML
{"Table": {"httpStatus":"200","primary_key": "val1","key1":
   "value1","key2": "value2"}}
<tables>
     <httpStatus value="200"/>
     <table primary_key="val1" key1="value1" key2="value2" />
</tables>
{"Student": {"httpStatus":"200","student_id": "005802615","name":
   "Edison Lascano","address": "2199 McLaughlin Ave"}}
<students>
<httpStatus value="200"/>
<student student_id="005802615" name="Edison Lascano"
  address="McLaughlin" />
</students>
Web Services
• The basis of web 2.0 and many distributed
  applications currently
• Public APIs are published by web 2.0
  providers in SOAP, REST, XML-RPC, js.
  Private APIs are used internally.
  REST http://weather.yahooapis.com/forecastrss?w=2502265
  SOAP http://www.programmableweb.com/api/bing

• MASHUPS (main users of Web APIs)
  – Public APIs + local APIs + My Application
  – Don't develop what is done, use others'
    resources. Low coupling. But, APIs may
    disappear at any moment, Yahoo search.
API´s
Technology
Web Services in Web 2.0
• http://www.programmableweb.com .
  Cloud Services providers publish their
  Web APIs: AWS, Google App Engine...
• Technology:
-Tools, Languages, Platforms: Java, .Net,
  Python, php, Ruby, …
-Distributed Objects: JEE-EJBs, .Net Remoting;
  ORMs: Persistent Units, JPAs: Linq,
  Hibernate, Eclipse Link
-Clients: desktop, gadgets, widgets, mobiles,
  web, Ajax, Flex, JavaFX, Spring... Client-
SOAP Web Services
• Simple Object Access Protocol,
  acronym dropped after 2003, it is a
  service oriented protocol

• Microsoft begins in 1998, currently
  supported by the World Wide
  Consortium W3C

• Usually Service verb form: URLs
  Uniform Resource Locator “getItem”
Ser     UDDI
                                                    vice
                                                    Reg
                                                    istry

 SOAP Web Services




                                                L




                                                              W
                                            W SD




                                                            SD
                                                              L
                                            SOAP Messages
                                     Ser                          Ser
                                     vice                         vice

• SOAP: protocol                     Pro
                                     vide
                                     r
                                                                  Con
                                                                  sum
                                                                   er
  – SOAP envelope: SOAP Header+SOAP Body
  – It uses XML
• WSDL: IDL
  – Description of the methods, parameters, types
  – XML
• UDDI: Universal Description Discovery
  and Integration
  – The service broker
  – Besides the Web Server
What is a SOAP Web Service?
• Distributed Objects?
• Is it RMI?
• Is it RPC?
  – Every Web Service has a set of
    operations,
  – Two libraries in Java to program ws
    are JAX-WS and JAX-RPC.
REST
Representation State Transfer
• Architectural style
• Resource Oriented
• Spread from 2000, It looks like they
  always existed, but became to be
  noticed and well organized/architected
  after Roy Fielding Dissertation.
 http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

• Fielding is one of the authors of HTTP.
REST
• A representation of the resource is
  returned
  – Resource: Noun form: URI, Uniform
    Resource Identifier
• HTTP Methods: GET, PUT, POST,
  DELETE
• WADL: Web Application Def Lang
  – Unlike Soap, WADL is not mandatory to
    discover the resource, the providers supply
    development documentation: URI´s lists.
URIs / URLs
http://ajax.googleapis.com/ajax/services/language/translate?q=be%20happy?&v=1.0&langpair=en |ko


http://www.youtube.com/embed/u1zgFlCw8Aw?autoplay=1&origin=http://example.com


http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Quito&results=2
http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Quito&results=


http://weather.yahooapis.com/forecastrss?w=2502265


http://developer.yahoo.com/weather/


https://www.dropbox.com/developers/start


https://api.dropbox.com/1/oauth/request_token
RESTful Web services
   “If an application complies with the 6 REST
   constraints, then it is RESTful” Roy Fielding

• Three Client Constraints:
     •   C/S, for separation of concerns
     •   Stateless, Client holds the session state
     •   Cacheable,To improve scalability and
         performance, but be careful of getting outdated
         information
• Three Coding Constraints:
     • Layered Systems, they do not know about
       each other implementations, the URI is enough
     • Code on Demand, Javascript, any or “none”
     • Uniform Interface, for all WSs.
RESTful Uniform Interface
• HTTP Request/Response Codes:
     • 200 OK; 300 Redirect; 400 Error, e.g. 404
• Noun form URIs
 . http://www.example.com/resources/
 . http://www.example.com/resources/item1
 . http://www.example.com/resources/item1/json
 . http://www.example.com/resources/item1?format=json

• HTTP Methods
     •   GET /items/{id} # read an Item
     •   POST /items/{id} # create an Item
     •   PUT      /items/{id} # update an Item
     •   DELETE /items/{id} # delete an Item
Some REST advice
• Use the standard HTTP methods, not
  as in SOAP, that you must create new
  methods for every requirement.
• Opportunities  Improve your REST
  design
  – Provide one URI for every resource
  – Minimize the use of QUERY_STRING,
    prefer items/1 over items?id=1
  – Logical over physical URIs, items/1 over
    items/1.html
  – No verbs in the URI, they are resources
More REST advice
• Use hyperlinks in the Response when need
  to communicate an executed action ack/nack.
• Use / to represent parent/child relationships.
  e.g. stock/items1 doctor1/patients/1
• Use GET to allow the client retrieving a
  resource representation, not POST
• Use POST to update a big object, so the URI
  will not be long and your data can not be
  seen in the URI.
• Use GET, PUT, POST, DELETE properly.
The REST way of
                  implementing the Web
                        Services
    HTTP GET request                  URI1
                                                                             Items List
             Response
         (HTML/XML/JSON...)        HTTP response



    HTTP GET request                  URI
                                                   Web Server                   Item
             Response
         (HTML/XML/JSON...)        HTTP response



                     PO
HTTP POST     (HTML/XML/JSON...)      URI
                                                                                PO
 URL to submitted PO               HTTP response

  Adapted from: Roger L. Costello, “REST (Representational State Transfer), XML Technology Course”
Web app architecture designs
• Client ↔ REST ↔ EJB ↔ DB (EIS)
• Client ↔ SOAP ↔ EJB ↔ DB (EIS)
  Client ↔ REST ↔ JPA ↔ DB (EIS)
  Client ↔ REST ↔ DB (EIS), SOAP can be
  interchanged with REST in any case
• Client ↔ REST ↔ .NET ↔ ORM ↔ DB(EIS)
  Client ↔ SOAP ↔ .NET ↔ ORM ↔ DB(EIS)
  .NET can be replaced by any other
  Distributed Objects technology.
SOAP web service lab
• Netbeans 7.2 full version
• Create a new Web Application, then a
  create a new “Web service”
• Implement a new operation using the
  wizards, finally test the Web Service
  and take a look of the generated WSDL
  file.
REST Web Service Lab
• Create a new Web Application
• Create new RESTful web services
  – From patterns, simple root resource
  – New RESTful web services from database,
    finally test the RESTful web services, read
    the WADL file and then try some URIs to
    read the XML/JSON data returned.
Web Services (Java)

SOAP             REST
JAX-WS           JAX-RS
  annotations:     annotations:
 @WebService      @Path
 @WebMethod       @GET, @PUT, …
 @WebParam        @PathParam,
                   @QueryParam
Web Services clients

SOAP               REST
JAX-WS stub        Consume through
 generation from    simple HTTP
 WSDL import        calls from Java, js
                   WADL is not
                    needed
Motivation for REST
"The motivation for developing REST was to create an architectural model for
how the Web should work, such that it could serve as the guiding framework
for the Web protocol standards.

REST has been applied to describe the desired Web architecture, help identify
existing problems, compare alternative solutions, and ensure that protocol
extensions would not violate the core constraints that make the Web successful."

                                             - Roy Fielding

Contenu connexe

Tendances

Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap uipkslide28
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 SlidesSuraj Gupta
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
 
Angular 6 Form Validation with Material
Angular 6 Form Validation with MaterialAngular 6 Form Validation with Material
Angular 6 Form Validation with MaterialMalika Munaweera
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepGuo Albert
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webserviceDong Ngoc
 
SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersShivanand Arur
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overviewOleksii Prohonnyi
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 

Tendances (20)

Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Ajax Presentation
Ajax PresentationAjax Presentation
Ajax Presentation
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
Why HATEOAS
Why HATEOASWhy HATEOAS
Why HATEOAS
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Angular 6 Form Validation with Material
Angular 6 Form Validation with MaterialAngular 6 Form Validation with Material
Angular 6 Form Validation with Material
 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSS
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
 
SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET Developers
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overview
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 

Similaire à Soap and Rest

Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)Heartin Jacob
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overviewRaveendra Bhat
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
Restful web services rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financialRule_Financial
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
Esri Web Applications February11 2011
Esri Web Applications February11 2011Esri Web Applications February11 2011
Esri Web Applications February11 2011delmelle
 
Java Web services
Java Web servicesJava Web services
Java Web servicesSujit Kumar
 
Ruby Conf Preso
Ruby Conf PresoRuby Conf Preso
Ruby Conf PresoDan Yoder
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Jackson F. de A. Mafra
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restfultom_li
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using SwaggerHong-Jhih Lin
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restishGrig Gheorghiu
 

Similaire à Soap and Rest (20)

Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)Intro To Web and Web Services (REST Series 01)
Intro To Web and Web Services (REST Series 01)
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overview
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
Restful web services rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financial
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
Esri Web Applications February11 2011
Esri Web Applications February11 2011Esri Web Applications February11 2011
Esri Web Applications February11 2011
 
Web Services
Web ServicesWeb Services
Web Services
 
Java Web services
Java Web servicesJava Web services
Java Web services
 
Ruby Conf Preso
Ruby Conf PresoRuby Conf Preso
Ruby Conf Preso
 
Linked services
Linked servicesLinked services
Linked services
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
 
zendframework2 restful
zendframework2 restfulzendframework2 restful
zendframework2 restful
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
Rest web service
Rest web serviceRest web service
Rest web service
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Services
ServicesServices
Services
 
Why do you need REST
Why do you need RESTWhy do you need REST
Why do you need REST
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 

Plus de Edison Lascano

eXtreme Programming May Be Embedded inside Scrum
eXtreme Programming May Be Embedded inside ScrumeXtreme Programming May Be Embedded inside Scrum
eXtreme Programming May Be Embedded inside ScrumEdison Lascano
 
An Infectious Disease Surveillance Simulation (IDSS) in the Cloud
An Infectious Disease Surveillance Simulation (IDSS) in the CloudAn Infectious Disease Surveillance Simulation (IDSS) in the Cloud
An Infectious Disease Surveillance Simulation (IDSS) in the CloudEdison Lascano
 
UML for Aspect Oriented Design
UML for Aspect Oriented DesignUML for Aspect Oriented Design
UML for Aspect Oriented DesignEdison Lascano
 
Hw8 GoF state, strategy, tempate method, visitor
Hw8 GoF state, strategy, tempate method, visitorHw8 GoF state, strategy, tempate method, visitor
Hw8 GoF state, strategy, tempate method, visitorEdison Lascano
 
Hw7 mediator memento observer
Hw7 mediator memento observerHw7 mediator memento observer
Hw7 mediator memento observerEdison Lascano
 
Hw6 interpreter iterator GoF
Hw6 interpreter iterator GoFHw6 interpreter iterator GoF
Hw6 interpreter iterator GoFEdison Lascano
 
Hw5 proxy, chain of responsability, command
Hw5 proxy, chain of responsability, commandHw5 proxy, chain of responsability, command
Hw5 proxy, chain of responsability, commandEdison Lascano
 
Hw4 composite decorator facade flyweight
Hw4 composite decorator facade flyweightHw4 composite decorator facade flyweight
Hw4 composite decorator facade flyweightEdison Lascano
 
Hw12 refactoring to factory method
Hw12 refactoring to factory methodHw12 refactoring to factory method
Hw12 refactoring to factory methodEdison Lascano
 
Hw11 refactoringcreation
Hw11 refactoringcreationHw11 refactoringcreation
Hw11 refactoringcreationEdison Lascano
 
GoF Patterns: Prototype, Singleton, Adapter, Bridge
GoF Patterns: Prototype, Singleton, Adapter, BridgeGoF Patterns: Prototype, Singleton, Adapter, Bridge
GoF Patterns: Prototype, Singleton, Adapter, BridgeEdison Lascano
 
Abstract Factory and Builder patterns
Abstract Factory and Builder patternsAbstract Factory and Builder patterns
Abstract Factory and Builder patternsEdison Lascano
 
GoF design patterns chapters 1 and 2
GoF design patterns chapters 1 and 2GoF design patterns chapters 1 and 2
GoF design patterns chapters 1 and 2Edison Lascano
 

Plus de Edison Lascano (13)

eXtreme Programming May Be Embedded inside Scrum
eXtreme Programming May Be Embedded inside ScrumeXtreme Programming May Be Embedded inside Scrum
eXtreme Programming May Be Embedded inside Scrum
 
An Infectious Disease Surveillance Simulation (IDSS) in the Cloud
An Infectious Disease Surveillance Simulation (IDSS) in the CloudAn Infectious Disease Surveillance Simulation (IDSS) in the Cloud
An Infectious Disease Surveillance Simulation (IDSS) in the Cloud
 
UML for Aspect Oriented Design
UML for Aspect Oriented DesignUML for Aspect Oriented Design
UML for Aspect Oriented Design
 
Hw8 GoF state, strategy, tempate method, visitor
Hw8 GoF state, strategy, tempate method, visitorHw8 GoF state, strategy, tempate method, visitor
Hw8 GoF state, strategy, tempate method, visitor
 
Hw7 mediator memento observer
Hw7 mediator memento observerHw7 mediator memento observer
Hw7 mediator memento observer
 
Hw6 interpreter iterator GoF
Hw6 interpreter iterator GoFHw6 interpreter iterator GoF
Hw6 interpreter iterator GoF
 
Hw5 proxy, chain of responsability, command
Hw5 proxy, chain of responsability, commandHw5 proxy, chain of responsability, command
Hw5 proxy, chain of responsability, command
 
Hw4 composite decorator facade flyweight
Hw4 composite decorator facade flyweightHw4 composite decorator facade flyweight
Hw4 composite decorator facade flyweight
 
Hw12 refactoring to factory method
Hw12 refactoring to factory methodHw12 refactoring to factory method
Hw12 refactoring to factory method
 
Hw11 refactoringcreation
Hw11 refactoringcreationHw11 refactoringcreation
Hw11 refactoringcreation
 
GoF Patterns: Prototype, Singleton, Adapter, Bridge
GoF Patterns: Prototype, Singleton, Adapter, BridgeGoF Patterns: Prototype, Singleton, Adapter, Bridge
GoF Patterns: Prototype, Singleton, Adapter, Bridge
 
Abstract Factory and Builder patterns
Abstract Factory and Builder patternsAbstract Factory and Builder patterns
Abstract Factory and Builder patterns
 
GoF design patterns chapters 1 and 2
GoF design patterns chapters 1 and 2GoF design patterns chapters 1 and 2
GoF design patterns chapters 1 and 2
 

Soap and Rest

  • 1. Web Services The SOAP & The REST Edison Lascano
  • 2. Web Services Web Services: Method of communication for web applications (Internet, intranet, extranet, desktop, mobile) . Application layer : Mainly the HTTP protocol and port 80. Port and protocol may change, e.g. SMTP Message Formats: XML, JSON, RSS, longer than binary. MIME types match resource representations.
  • 3. JSON / XML {"Table": {"httpStatus":"200","primary_key": "val1","key1": "value1","key2": "value2"}} <tables> <httpStatus value="200"/> <table primary_key="val1" key1="value1" key2="value2" /> </tables> {"Student": {"httpStatus":"200","student_id": "005802615","name": "Edison Lascano","address": "2199 McLaughlin Ave"}} <students> <httpStatus value="200"/> <student student_id="005802615" name="Edison Lascano" address="McLaughlin" /> </students>
  • 4. Web Services • The basis of web 2.0 and many distributed applications currently • Public APIs are published by web 2.0 providers in SOAP, REST, XML-RPC, js. Private APIs are used internally. REST http://weather.yahooapis.com/forecastrss?w=2502265 SOAP http://www.programmableweb.com/api/bing • MASHUPS (main users of Web APIs) – Public APIs + local APIs + My Application – Don't develop what is done, use others' resources. Low coupling. But, APIs may disappear at any moment, Yahoo search.
  • 7. Web Services in Web 2.0 • http://www.programmableweb.com . Cloud Services providers publish their Web APIs: AWS, Google App Engine... • Technology: -Tools, Languages, Platforms: Java, .Net, Python, php, Ruby, … -Distributed Objects: JEE-EJBs, .Net Remoting; ORMs: Persistent Units, JPAs: Linq, Hibernate, Eclipse Link -Clients: desktop, gadgets, widgets, mobiles, web, Ajax, Flex, JavaFX, Spring... Client-
  • 8. SOAP Web Services • Simple Object Access Protocol, acronym dropped after 2003, it is a service oriented protocol • Microsoft begins in 1998, currently supported by the World Wide Consortium W3C • Usually Service verb form: URLs Uniform Resource Locator “getItem”
  • 9. Ser UDDI vice Reg istry SOAP Web Services L W W SD SD L SOAP Messages Ser Ser vice vice • SOAP: protocol Pro vide r Con sum er – SOAP envelope: SOAP Header+SOAP Body – It uses XML • WSDL: IDL – Description of the methods, parameters, types – XML • UDDI: Universal Description Discovery and Integration – The service broker – Besides the Web Server
  • 10. What is a SOAP Web Service? • Distributed Objects? • Is it RMI? • Is it RPC? – Every Web Service has a set of operations, – Two libraries in Java to program ws are JAX-WS and JAX-RPC.
  • 11. REST Representation State Transfer • Architectural style • Resource Oriented • Spread from 2000, It looks like they always existed, but became to be noticed and well organized/architected after Roy Fielding Dissertation. http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm • Fielding is one of the authors of HTTP.
  • 12. REST • A representation of the resource is returned – Resource: Noun form: URI, Uniform Resource Identifier • HTTP Methods: GET, PUT, POST, DELETE • WADL: Web Application Def Lang – Unlike Soap, WADL is not mandatory to discover the resource, the providers supply development documentation: URI´s lists.
  • 13. URIs / URLs http://ajax.googleapis.com/ajax/services/language/translate?q=be%20happy?&v=1.0&langpair=en |ko http://www.youtube.com/embed/u1zgFlCw8Aw?autoplay=1&origin=http://example.com http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Quito&results=2 http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Quito&results= http://weather.yahooapis.com/forecastrss?w=2502265 http://developer.yahoo.com/weather/ https://www.dropbox.com/developers/start https://api.dropbox.com/1/oauth/request_token
  • 14. RESTful Web services “If an application complies with the 6 REST constraints, then it is RESTful” Roy Fielding • Three Client Constraints: • C/S, for separation of concerns • Stateless, Client holds the session state • Cacheable,To improve scalability and performance, but be careful of getting outdated information • Three Coding Constraints: • Layered Systems, they do not know about each other implementations, the URI is enough • Code on Demand, Javascript, any or “none” • Uniform Interface, for all WSs.
  • 15. RESTful Uniform Interface • HTTP Request/Response Codes: • 200 OK; 300 Redirect; 400 Error, e.g. 404 • Noun form URIs . http://www.example.com/resources/ . http://www.example.com/resources/item1 . http://www.example.com/resources/item1/json . http://www.example.com/resources/item1?format=json • HTTP Methods • GET /items/{id} # read an Item • POST /items/{id} # create an Item • PUT /items/{id} # update an Item • DELETE /items/{id} # delete an Item
  • 16. Some REST advice • Use the standard HTTP methods, not as in SOAP, that you must create new methods for every requirement. • Opportunities  Improve your REST design – Provide one URI for every resource – Minimize the use of QUERY_STRING, prefer items/1 over items?id=1 – Logical over physical URIs, items/1 over items/1.html – No verbs in the URI, they are resources
  • 17. More REST advice • Use hyperlinks in the Response when need to communicate an executed action ack/nack. • Use / to represent parent/child relationships. e.g. stock/items1 doctor1/patients/1 • Use GET to allow the client retrieving a resource representation, not POST • Use POST to update a big object, so the URI will not be long and your data can not be seen in the URI. • Use GET, PUT, POST, DELETE properly.
  • 18. The REST way of implementing the Web Services HTTP GET request URI1 Items List Response (HTML/XML/JSON...) HTTP response HTTP GET request URI Web Server Item Response (HTML/XML/JSON...) HTTP response PO HTTP POST (HTML/XML/JSON...) URI PO URL to submitted PO HTTP response Adapted from: Roger L. Costello, “REST (Representational State Transfer), XML Technology Course”
  • 19. Web app architecture designs • Client ↔ REST ↔ EJB ↔ DB (EIS) • Client ↔ SOAP ↔ EJB ↔ DB (EIS) Client ↔ REST ↔ JPA ↔ DB (EIS) Client ↔ REST ↔ DB (EIS), SOAP can be interchanged with REST in any case • Client ↔ REST ↔ .NET ↔ ORM ↔ DB(EIS) Client ↔ SOAP ↔ .NET ↔ ORM ↔ DB(EIS) .NET can be replaced by any other Distributed Objects technology.
  • 20. SOAP web service lab • Netbeans 7.2 full version • Create a new Web Application, then a create a new “Web service” • Implement a new operation using the wizards, finally test the Web Service and take a look of the generated WSDL file.
  • 21. REST Web Service Lab • Create a new Web Application • Create new RESTful web services – From patterns, simple root resource – New RESTful web services from database, finally test the RESTful web services, read the WADL file and then try some URIs to read the XML/JSON data returned.
  • 22. Web Services (Java) SOAP REST JAX-WS JAX-RS annotations: annotations: @WebService @Path @WebMethod @GET, @PUT, … @WebParam @PathParam, @QueryParam
  • 23. Web Services clients SOAP REST JAX-WS stub Consume through generation from simple HTTP WSDL import calls from Java, js WADL is not needed
  • 24. Motivation for REST "The motivation for developing REST was to create an architectural model for how the Web should work, such that it could serve as the guiding framework for the Web protocol standards. REST has been applied to describe the desired Web architecture, help identify existing problems, compare alternative solutions, and ensure that protocol extensions would not violate the core constraints that make the Web successful." - Roy Fielding

Notes de l'éditeur

  1. Openness is achieved by specifying and documenting the key software interfaces of a system and making them available to software developers.&quot;, pp. 14 Mechanisms for achieving openness: Programmer interfaces for system calls Programmer-loadable resource managers (device drivers) Core principles that seem to improve openness: Encapsulation - The hiding of design decisions within the module that they affect Low coupling - The reduction of dependencies between modules.
  2. Eight forms of transparency: Access transparency enables local and remote information objects to be accessed using identical operations Location transparency enables objects to be accessed without knowledge of their location Concurrency transparency enables several processes to operate concurrently using shared objects with interference between them Replication transparency enables multiple instances of an objects to be used to increase reliability and performance with knowledge of the replicas by users or application programs. Failure transparency enables the concealment of faults, allowing users and application programs to complete their tasks despite the failure of hardware or software components. Migration transparency allows the movement of objects within a system without affecting the operation of users or application programs. Performance transparency allows the system to be reconfigured to improve performance as loads vary Scaling transparency allows the system and applications to expand in scale without changes to the system structure or the application’s algorithms.
  3. Definition: “A distributed system is a collection of autonomous computers linked by a network, with software designed to produced an integrated computing facility.” Coulouris, pp. 1
  4. A distributed system is the sharing of resources in independent and perhaps heterogeneous computer systems. Coulouris characterizes a resource as anything that can be shared usefully. A more traditional and perhaps not so abstract definition says that a resource is anything used in a computerized system to accomplish a task.
  5. Physical Resource Examples: CPUs, Memory, Disk space, Clocks, Displays, Keyboards, Printers Virtual resources A virtual resource is a simulation of a physical resource. Virtual resources are sometimes implemented by time-sharing a physical resource, such as with virtual machines and virtual memory. In other cases, a virtual resource may be simulated on some unrelated physical device. For example, a display may be simulated in memory. Examples: Virtual memory, Virtual displays, Virtual keyboards, Other kinds of input devices Logical resources Logical resources are abstract entities which are eventually bound to physical and/or virtual resources. Logical resources eliminate the hassle of dealing with actual or virtual resource identifications. Operating systems are usually responsible for binding logical resources to physical and/or virtual resources. Examples: Units of work, Processes, Files, Procedure libraries, Shared programs
  6. (Broaden discussion and generalize) Challenges of resource sharing: What challenges arise from resource sharing in a centralized multi-user system? Are these challenges present in distributed systems? Are there new challenges in distributed systems?
  7. Illustrate each of these problems by stopping the server restarting server and disconnecting lines entering illegal ids look at packaging of Parcel Data look at sequential server design Which of these problems would exist in a centralized system? Which of these problems would exist in a single user system?
  8. Key design questions: What are the costs of achieving a degree of fault tolerance? What are the benefits of fault tolerance? What degree of fault tolerance does a given application require or justify?
  9. Concurrency in a computer system is when two or more processes execute simultaneously on separate processes. Single processor systems can give the illusion of concurrency by interleaving process execution. This is not true concurrency; rather, it is simulated concurrency True concurrent execution requires multiple processors. Opportunities for concurrency can occur in distributed systems in several ways: Coulouris, p. 16 Many users simultaneously invoke commands or interact with application programs Many server processes run concurrently, each responding to different requests for client processes.
  10. Scalability We can increase the number of resources in a distributed system by adding more computer systems and communication channels The cost of increasing resources in a distributed system is usually less than the cost of scaling a centralized system. Why? However, system designers need to count communication delays as part of the cost. Scalable distributed systems have the potential to operate effectively and efficiently at many different levels (sizes). Work is distributed Loads can be balanced across the network Scalability is not an automatic property of distributed systems Designers need to consider the dynamic addition or removal of resources Designers must consider how the work is distributed Designers should consider dynamic load balancing
  11. Openness &quot;The openness of a computer system is the characteristic that determines whether the system can be extended in various ways.&quot;, pp. 14 This applies to both the addition of new kinds of resources and functionality with respect to those resources Scalability is a simple type of openness involving the addition of resources of the same kinds as those already in the system.
  12. Transparency &quot;Transparency is defined as the concealment from the user or the application programmer of the separation of components in a distributed system, so that the system is perceived as a whole rather than a collection of independent components.&quot; pp. 20