1 / 72

Comparative Integrated Systems CIS007-3

Comparative Integrated Systems CIS007-3. Week 12: More About Web Services – SOAP and RESTful. Sue Brandreth. Topics covered. Web Services More on Web Services standards Overview of SOAP Overview of RESTFul. Communications and Standards.

kerfootm
Télécharger la présentation

Comparative Integrated Systems CIS007-3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Comparative Integrated SystemsCIS007-3 Week 12: More About Web Services – SOAP and RESTful Sue Brandreth

  2. Topics covered • Web Services • More on Web Services standards • Overview of SOAP • Overview of RESTFul

  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. 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. Protocol Stack of Web Services Dr. M. E. AYDIN

  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:

  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, findand bind paradigm. 1. Publish2. 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.

  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. 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. Dr. M. E. AYDIN

  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….

  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

  21. REST vs. SOAP

  22. REST vs. SOAP

  23. XML

  24. XML • XML stands for EXtensibleMarkup 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/standards/xml/ XML Technology

  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 <strong> pre-defined. In XML you would need to define this in the context of your document.

  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)

  27. Schema <?xml version="1.0"?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns=“document" > <xs:element name = “DOCUMENT”> <xs:element name=“CUSTOMER"> </xs:element> </xs:element> </xs:schema> Simple schema saved as order.xsd <?xml version=“1.0”?> <DOCUMENT xmlns=“document” xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Xsi:schemaLocation=“order.xsd”> <DOCUMENT> <CUSTOMER>sam smith</CUSTOMER> <CUSTOMER>sam smith</CUSTOMER> </DOCUMENT> XML document derived from schema.

  28. XML v. HTML 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. An HTML Example: <html> <body> <h2>John Doe</h2> <p>2 BackroadsLane<br/> New York<br> 045935435<br> john.doe@gmail.com<br/> </p> </body> </html>

  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.

  30. XML v. HTML Now look at the following: <?xml version=1.0?> <contact> <name>John Doe</name> <address>2 Backroads Lane</address> <country>New York</country> <phone>045935435</phone> <email>john.doe@gmail.com</email> </contact> In this case: • The information contained is being marked, but not for displaying. • Readable by both human and machines.

  31. WSDL

  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 communicationsprotocol 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. WSDL Structure Dr. M. E. AYDIN

  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: • 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.

  36. WSDL Document <message name="GetStockPriceRequest"> <part name="stock" type="xs:string"/> </message> <message name="GetStockPriceResponse"> <part name="value" type="xs:string"/> </message> <portType name=“StocksRates"> <operation name=“GetStockPrice"> <input message=“GetStockPriceRequest"/> <output message=“GetStockPriceResponse"/> </operation></portType>

  37. UDDI

  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. UDDI Dr. M. E. AYDIN

  40. SOAP

  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.

  42. 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

  43. Soap Structure • Each SOAP message will have: • An Envelope • A Header (optional) • A Body • The Body may contain a Fault element

  44. 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.

  45. 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 .

  46. Anatomy of a SOAP Message <?xml version=‘1.0’ encoding=‘UTF-8’?> 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”> <SOAP-ENV:Header> </SOAP-ENV:Header <SOAP_ENV:Body> </SOAP-ENV:Body> </SOAP-ENV:Envelope> </SOAP-ENV:Envelope>

  47. SOAP Request POST /InStock HTTP/1.1 Host: www.stock.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: 150 <?xml version="1.0"?> <soap:Envelopexmlns:soap= "http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle=http://www.w3.org/2001/12/soap-encoding”> <soap:Bodyxmlns:m="http://www.stock.org/stock">     <m:GetStockPrice> <m:StockName>IBM</m:StockName>      </m:GetStockPrice> </soap:Body> </soap:Envelope>

  48. SOAP Response HTTP/1.1 200 OK Content-Type: application/soap; charset=utf-8 Content-Length: 126 <?xml version="1.0"?> <soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Bodyxmlns:m="http://www.stock.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>

  49. 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 • <faultcode> and <faultstring> are required. </SOAP-ENV:Envelope>

  50. A SOAP Fault <?xml version=‘1.0’ encoding=‘UTF-8’?> <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”> <SOAP_ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Test fault</faultstring> <faultactor>/soap/servlet/rpcrouter</faultactor> <detail> .. </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope> </SOAP-ENV:Envelope>

More Related