Download presentation
Presentation is loading. Please wait.
Published byTodd Burns Modified over 8 years ago
1
09/06/2016 1 Comparative Integrated Systems CIS007-3 Sue Brandreth Week 12: More About Web Services – SOAP and RESTful
2
09/06/2016 2 Topics covered Web Services More on Web Services standards Overview of SOAP Overview of RESTFul
3
09/06/2016 3 Communications and Standards Efficient (or indeed any) communication is dependent on a shared vocabulary and grammar. Because web services deals with inter- organisation communication these must be universal standards.
4
09/06/2016 4 Underlying Standards The basic standards for web services are: XML (Extensible Markup Language) SOAP (Simple Object Access Protocol) WSDL (Web Services Description Language) UDDI (Universal Description, Discovery and Integration) Standards are still volatile and in the process of development.
5
Dr. M. E. AYDIN Protocol Stack of Web Services
6
Web Service Standards The following standards play key roles in Web services: Universal Description, Discovery and Integration (UDDI), Web Services Description Language (WSDL), Web Services Inspection Language (WSIL), SOAP, and Web Services Interoperability (WS-I). The relationship between these standards is shown: 09/06/2016 6
7
7 Web Services Architecture Web Services involve three major roles Service Provider Service Registry Service Consumer Three major operations surround web services Publishing – making a service available Finding – locating web services Binding – using web services
8
The Web Service Model The Web Services model follows the publish, find and bind paradigm. 1. Publish 2. Find 3. Bind/Invoke Web Service Registry Web Service Provider Web Service Client
9
Making a Service Available In order for someone to use your service they have to know about it. To allow users to discover a service it is published to a registry (UDDI). To allow users to interact with a service you must publish a description of it’s interface (methods and arguments). This is done using WSDL.
10
Making a Service Available Once you have published a description of your service you must have a host set up to serve it. A web server is often used to deliver services (although custom application – application communication is also possible).
11
The old transfer protocols are still there Like grid architecture web services are layered on top of existing, mature transfer protocols. HTTP, SMTP are still used over TCP/IP to pass the messages. Web services, like grids, can be seen as a functionality enhancement to the existing technologies.
12
XML All Web Services documents are written in XML XML Schema are used to define the elements used in Web Services communication
13
SOAP Actually used to communicate with the Web Service Both the request and the response are SOAP messages The body of the message (whose grammar is defined by the WSDL) is contained within a SOAP “envelope” “Binds” the client to the web service
14
WSDL Describes the Web Service and defines the functions that are exposed in the Web Service Defines the XML grammar to be used in the messages Uses the W3C Schema language
15
UDDI UDDI is used to register and look up services with a central registry Service Providers can publish information about their business and the services that they offer Service consumers can look up services that are available by Business Service category Specific service
16
Types of Web Services On a technical level, web services can be implemented in various ways. The two main types of web services can be distinguished as "big“ or “SOAP/XML-based” web services and "RESTful" web services. 09/06/2016 16
17
Request-Response Web Services Currently the most common implementation of Web Services Work in a very simple ‘request – response’ paradigm For Example: A Weather Service– simple request for weather in an area, simple response with the weather report An Airline special offers service – travel agents would simply make requests for latest offers and would receive the offers as a response
18
Dr. M. E. AYDIN SOAP - RPC for Web Services One of the primary concerns of Web-based programmers was how to transmit data in an interoperable manner. At the bottom-most layer is the XML standard that addresses this. SOAP (Simple Object Access Protocol) is an XML-based mechanism for messaging and RPC (Remote Procedure Calls). It addresses the fundamental problems of firewall traversal in RPC systems by using HTTP as the transport protocol. SOAP is the protocol used for invoking the service.
19
RESTful Web Services REST is well suited for basic, ad hoc integration scenarios. RESTful web services, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service-API definitions. In Java, JAX-RS provides the functionality for Representational State Transfer (RESTful) web services. Relatively inexpensive to develop…. 09/06/2016 19
20
RESTful Web Services The following principles encourage RESTful applications to be simple, lightweight, and fast: Resource identification through URI Uniform interface Self-descriptive messages Stateful interactions through hyperlinks 09/06/2016 20
21
REST vs. SOAP
23
XML 09/06/2016 23
24
XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe data. It is a hierarchical data description language It is a sub set of SGML a general document markup language designed for the American millitary. XML tags are not predefined. You must define your own tags. The prefect choice for enabling cross-platform data communication in Web Services. See http://www.w3.org/XML/ Extensible Markup Language (XML)http://www.w3.org/XML/ http://www.w3.org/standards/xml/http://www.w3.org/standards/xml/ XML Technology 09/06/2016 24
25
What is a Schema? A schema is the definition of the meaning of each of the tags within a XML document. Analogy: A HTML style sheet can be seen as a limited schema which only specifies the presentational style of HTML which refers to it. Example: in HTML the tag pre-defined. In XML you would need to define this in the context of your document. 09/06/2016 25
26
What is a Schema? A correct XML document must be both valid and well formed. Well formed means that the syntax must be correct and all tags must close correctly (eg ). Valid means that the document must conform to some XML definition ( a DTD or Schema). (Otherwise there can be no definition of what the tags mean) 09/06/2016 26
27
Schema <DOCUMENT xmlns=“document” xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Xsi:schemaLocation=“order.xsd”> sam smith <DOCUMENT xmlns=“document” xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Xsi:schemaLocation=“order.xsd”> sam smith Simple schema saved as order.xsd XML document derived from schema.
28
XML v. HTML An HTML Example: <html><body> John Doe John Doe 2 Backroads Lane 2 Backroads Lane New York New York 045935435 045935435 john.doe@gmail.com john.doe@gmail.com </body></html> 09/06/2016 28 HTML is a presentation markup language – provides no information about content. There is only one standard definition of all of the tags used in HTML. XML can define both presentation style and give information about content. XML relies on custom documents defining the meaning of tags.
29
XML v. HTML This will be displayed as: John Doe 2 Backroads Lane New York 045935435 John.doe@gmail.com HTML specifies how the document is to be displayed, and not what information is contained in the document. Hard for machine to extract the embedded information. Relatively easy for human. 09/06/2016 29
30
XML v. HTML Now look at the following: <contact> John Doe John Doe 2 Backroads Lane 2 Backroads Lane New York New York 045935435 045935435 john.doe@gmail.com john.doe@gmail.com </contact> In this case: The information contained is being marked, but not for displaying. Readable by both human and machines. 09/06/2016 30
31
WSDL 09/06/2016 31
32
WSDL WSDL stands for Web Services Description Language. WSDL is an XML vocabulary for describing Web services. It allows developers to describe Web Services and their capabilities, in a standard manner. WSDL specifies what a request message must contain and what the response message will look like in unambiguous notation. In other words, it is a contract between the XML Web service and the client who wishes to use this service. In addition to describing message contents, WSDL defines where the service is available and what communications protocol is used to talk to the service.
33
The WSDL Document Structure A WSDL document is just a simple XML document. It defines a web service using these major elements: port type - The operations performed by the web service. message - The messages used by the web service. types - The data types used by the web service. binding - The communication protocols used by the web service.
34
Dr. M. E. AYDIN WSDL Structure definition of types........ definition of a message.... definition of a port....... definition of a binding....
35
Web Services Description Language (WSDL) The Web Services Description Language (WSDL) forms the basis for the original Web Services specification. See diagram. The steps involved in providing and consuming a service are: 1. A service provider describes its service using WSDL. This definition is published to a repository of services. The repository could use Universal Description, Discovery, and Integration (UDDI). Other forms of directories could also be used. 09/06/2016 35
36
WSDL Document
37
UDDI 09/06/2016 37
38
UDDI UDDI stands for Universal Description, Discovery and Integration. UDDI is a directory for storing information about web services, like yellow pages. UDDI is a directory of web service interfaces described by WSDL.
39
Dr. M. E. AYDIN UDDI
40
SOAP 09/06/2016 40
41
SOAP SOAP and XML created the solution for the connectivity problems that earlier developers faced. SOAP is a standard XML based protocol that communicated over HTTP. We can think of SOAP as message format for sending messaged between applications using XML. It is independent of technology, platform and is extensible too. 09/06/2016 41
42
SOAP Messages SOAP provides a standard ‘envelope’ within which a message can be delivered. SOAP is mechanism (protocol) for transferring information (messages) between applications which may be widely distributed. SOAP says nothing about the content of the message – the sender and the receiver must understand the message for themselves. SOAP is part of a communication stack. 09/06/2016 42
43
Soap Structure The envelope wraps the entire soap document The header contains allows additional information to be passed as well as the body of the document – e.g. authentication The body element contains the core of the SOAP document – this will contain either the RPC call or the XML message itself The fault information will contain any exception information
44
Soap Structure Each SOAP message will have: An Envelope A Header (optional) A Body The Body may contain a Fault element
45
SOAP SOAP originally stood for "Simple Object Access Protocol". Web Services expose useful functionality to Web users through a standard Web protocol called SOAP. Soap is an XML vocabulary standard to enable programs on separate computers to interact across any network. SOAP is a simple markup language for describing messages between applications. Soap uses mainly HTTP as a transport protocol. That is, HTTP message contains a SOAP message as its payload section. 09/06/2016 45
46
SOAP RPC SOAP RPC messages contain XML that represents a method call or method response The SOAP XML will be converted into a method call on the server and the response will be encoded into SOAP XML to be returned to the client
47
SOAP Characteristics SOAP has three major characteristics: Extensibility – security and WS-routing are among the extensions under development. Neutrality - SOAP can be used over any transport protocol such as HTTP, SMTP or even TCP. Independent - SOAP allows for any programming model.
48
Anatomy of a SOAP Message SOAP-ENV:Envelope xmlns:SOAP_ENV=“http://schemas.xmlsoap.org/soap/envel ope/” xmlns:xsi=“http://www.w3c.org/1999/XMLSchema- instance” xmlns:xsd=“http://www.w3c.org/1999/XMLSchema”> </SOAP-ENV:Header
49
SOAP Request POST /InStock HTTP/1.1 Host: www.stock.org Content-Type: application/soap+xml; charset=utf-8 Content- Length: 150 IBM IBM </soap:Envelope>
50
SOAP Response HTTP/1.1 200 OK Content-Type: application/soap; charset=utf-8 Content-Length: 126 34.5 34.5 </soap:Envelope>
51
SOAP Protocol Binding SOAPAction = “urn:soaphttpclient-action-uri” Host = localhost Content-Type = text/xml; charset=utf-8 Content-Length = 701 <SOAP-ENV:Envelope xmlns:SOAP_ENV=“http://schemas.xmlsoap.org/soap/envel ope/” xmlns:xsi=“http://www.w3c.org/1999/XMLSchema- instance” xmlns:xsd=“http://www.w3c.org/1999/XMLSchema”>
52
SOAP RPC SOAP RPC messages contain XML that represents a method call or method response The SOAP XML will be converted into a method call on the server and the response will be encoded into SOAP XML to be returned to the client
53
SOAP Faults SOAP errors are handled using a specialised envelope known as a Fault Envelope A SOAP Fault is a special element which must appear as an immediate child of the body element and are required.
54
A SOAP Fault <SOAP-ENV:Envelope xmlns:SOAP_ENV=“http://schemas.xmlsoap.org/soap/envel ope/” xmlns:xsi=“http://www.w3c.org/1999/XMLSchema- instance” xmlns:xsd=“http://www.w3c.org/1999/XMLSchema”> SOAP-ENV:Server Test fault /soap/servlet/rpcrouter..
55
A SOAP Fault Large quantities or binary data may not fit well into a XML SOAP message. In which case it can be sent ‘out of band’ by attaching it to a SOAP message Analogy : email attachments.
56
Attaching a File to a SOAP Message To add a file to a SOAP message a tag is added within the body of the message. <SOAP-ENV:Envelope xmlns:SOAP_ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“http://www.w3c.org/1999/XMLSchema-instance” xmlns:xsd=“http://www.w3c.org/1999/XMLSchema”>
57
SOAP Security SOAP uses HTTP as a transport protocol and hence can use HTTP security mainly HTTP over SSL. But, since SOAP can run over a number of application protocols (such as SMTP) security had to be considered. The WS-Security specification defines a complete encryption system.WS-Security specification
58
Representation State Transfer (REST) Representation State Transfer (REST) appeals to developers because it has a simpler style that makes it easier to use than SOAP. It also less verbose so that less volume is sent when communicating. The interaction is illustrated in the figure below.
59
Representation State Transfer (REST) Representational State Transfer (REST) is a style of architecture based on a set of principles that describe how networked resources are defined and addressed. These principles were first described in 2000 by Roy Fielding as part of his doctoral dissertation. http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm REST is an alternative to SOAP.
60
Representation State Transfer (REST) REST is a style of software architecture as opposed to a set of standards. As a result, such applications or architectures are sometimes referred to as RESTful or REST-style applications or architectures. REST has proved to be a popular choice for implementing Web Services. It is one of the options for Amazon Web Services and other popular web services.
61
Representation State Transfer (REST) An application or architecture considered RESTful or REST-style is characterized by: State and functionality are divided into distributed resources Every resource is uniquely addressable using a uniform and minimal set of commands (typically using HTTP commands of GET, POST, PUT, or DELETE over the Internet) The protocol is client/server, stateless, layered, and supports caching This is essentially the architecture of the Internet and helps to explain the popularity and ease-of-use for REST.
62
62 Hypertext Transfer Protocol (HTTP) A communications protocol Allows retrieving inter-linked text documents (hypertext) World Wide Web. HTTP Verbs HEAD GET POST PUT DELETE TRACE OPTIONS CONNECT BrowserWeb Server GET /index.html HTTP/1.1 Host: www.pitt.edu HTTP/1.1 200 OK Content-Type: text/html …
63
63 Representational State Transfer (REST) A style of software architecture for distributed hypermedia systems such as the World Wide Web. Introduced in the doctoral dissertation of Roy Fielding One of the principal authors of the HTTP specification. A collection of network architecture principles which outline how resources are defined and addressed
64
64 REST and HTTP The motivation for REST was to capture the characteristics of the Web which made the Web successful. URI Addressable resources HTTP Protocol Make a Request – Receive Response – Display Response Exploits the use of the HTTP protocol beyond HTTP POST and HTTP GET (HTTP PUT, HTTP DELETE)
65
65 REST - not a Standard REST is not a standard JSR 311: JAX-RS: The Java TM API for RESTful Web Services But it uses several standards: HTTP URL XML/HTML/GIF/JPEG/etc (Resource Representations) text/xml, text/html, image/gif, image/jpeg, etc (Resource Types, MIME Types)
66
66 Main Concepts Nouns (Resources) unconstrained i.e., http://example.com/employees/12345 Verbs constrained i.e., GET Representations constrained i.e., XML REST
67
67 Real Life Examples Google Maps Google AJAX Search API Yahoo Search API Amazon WebServices
68
68 REST and the Web The Web is an example of a REST system! All of those Web services that you have been using all these many years - book ordering services, search services, online dictionary services, etc - are REST-based Web services. Alas, you have been using REST, building REST services and you didn't even know it.
69
69 Resources The key abstraction of information in REST is a resource. A resource is a conceptual mapping to a set of entities Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in London"), a collection of other resources, a non-virtual object (ie. a person), and so on Represented with a global identifier (URI in HTTP) http://www.boeing.com/aircraft/747
70
70 Naming Resources REST uses URI to identify resources http://localhost/books/ http://localhost/books/ISBN-0011 http://localhost/books/ISBN-0011/authors http://localhost/classes http://localhost/classes/cs2650 http://localhost/classes/cs2650/students As you traverse the path from more generic to more specific, you are navigating the data
71
71 Verbs Represent the actions to be performed on resources HTTP GET HTTP POST HTTP PUT HTTP DELETE
72
72 HTTP GET How clients ask for the information they seek. Issuing a GET request transfers the data from the server to the client in some representation GET http://localhost/bookshttp://localhost/books Retrieve all books GET http://localhost/books/ISBN-0011021http://localhost/books/ISBN-0011021 Retrieve book identified with ISBN-0011021 GET http://localhost/books/ISBN-0011021/authorshttp://localhost/books/ISBN-0011021/authors Retrieve authors for book identified with ISBN-0011021
73
73 HTTP PUT, HTTP POST HTTP POST creates a resource HTTP PUT updates a resource POST http://localhost/books/http://localhost/books/ Content: {title, authors[], …} Creates a new book with given properties PUT http://localhost/books/isbn-111http://localhost/books/isbn-111 Content: {isbn, title, authors[], …} Updates book identified by isbn-111 with submitted properties
74
74 HTTP DELETE Removes the resource identified by the URI DELETE http://localhost/books/ISBN-0011http://localhost/books/ISBN-0011 Delete book identified by ISBN-0011
75
75 Representations How data is represented or returned to the client for presentation. Two main formats: JavaScript Object Notation (JSON) XML It is common to have multiple representations of the same data
76
76 Representations XML CS2650 Distributed Multimedia Software JSON {course {id: CS2650} {name: Distributed Multimedia Sofware} }
77
77 Why is it called "Representational State Transfer"? Resource Client http://www.boeing.com/aircraft/747 Boeing747.html The Client references a Web resource using a URL. A representation of the resource is returned (in this case as an HTML document). The representation (e.g., Boeing747.html) places the client application in a state. The result of the client traversing a hyperlink in Boeing747.html is another resource accessed. The new representation places the client application into yet another state. Thus, the client application changes (transfers) state with each resource representation --> Representation State Transfer! Fuel requirements Maintenance schedule...
78
78 Request (XML doc) Response (XML doc) Web/Proxy Server HTTP GET URL 1 HTTP Response doGet() Request (XML doc) Response (JSON doc) HTTP POST URL 1 HTTP Response doPost(id) REST Engine ( locate resource and generate response ) PO (XML doc) HTTP DELETE URL 1 doDelete() Response (TEXT doc) HTTP Response Architecture Style
79
79 REST Implementations Restlet http://www.restlet.org/ Project Zero http://www.projectzero.org GlassFish Jersey https://jersey.dev.java.net/ JBoss RESTeasy http://www.jboss.org/resteasy/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.