Download presentation
Presentation is loading. Please wait.
Published byJewel Glenn Modified over 9 years ago
1
1 Web Services Representation and Management of Data on the Web
2
2 "Web services are loosely coupled software components delivered over Internet standard technologies." "Web services are loosely coupled software components delivered over Internet standard technologies."
3
3 Example Scenario: Get Online Information Stock Exchange Stock Broker Application Get Stock Price Return Stock Price Return Stock Price
4
4 Example Scenario – Online Trade Book Store The Hobbit (5) Price: 25.95 Copies in Stock: 1 The Hobbit (5) Price: 25.95 Copies in Stock: 0 Book Store The Hobbit (5) Price: 20.95 Copies in Stock: 5 Buy The Hobbit (5) How Much? 20.95 Buy it The Hobbit (5) Price: 20.95 Copies in Stock: 4 The Hobbit (5) Price: 25.95 Copies in Stock: 1 The Hobbit (5) Price: 25.95 Copies in Stock: 0
5
5 Example Scenario: Grid Computation Grid Computation Using seamlessly the combined resources of many computers that are connected to the Internet
6
6 What is a Web Service? Self-contained, modular Web application that can be published, located and invoked across the Web A Web service can perform functions of varying complexities Once deployed, other applications (and other Web services) can discover and invoke the deployed service
7
7 Why is it Difficult to Use Ordinary Web Sites as Services? Consider an application that should return the price of the book “The Hobbit” –How can your application find suitable online stores? –How can your application find the price of the book in a Web page? –How can your application fill forms, if needed?
8
8 What is the price here? How can we find this URL?
9
9 Calling Remote Functions Could Help It would help if we could call functions, such as: –Amazon.getPrice(“The Hobbit") –Amazon.buyBook(“The Hobbit", myId) getPrice(…) The Internet
10
10 Difficulties in Using Remote Functions How can the calling application know in what language the functions are written? How can the application know what functions are available and what are their signatures? How can an application call a function that resides behind a firewall?
11
11 The Solution Use an agreed interface and a syntax that all applications are familiar with (e.g., XML) –For example, SOAP Use HTTP to transfer data through port 80 Use a standard for publishing methods, their signatures and their usage –For example, WSDL Use standard directory structures for publishing available services –For example, UDDI
12
12
13
13 Web Services that are Already Available Google search (http://www.google.com/apis) Weather reports Stock prices Currency exchanges Sending SMS messages, faxes Prices of books in Barnes and Nobles Dictionaries etc.
14
14 Implementing Web Services Programmers are given tools that spare the need of directly writing SOAP or WSDL documents In Java: –JAX-RPC: part of SUN tools for publishing and deploying Web Services –AXIS: Apache’s tool for handling Web services in Java
15
15 SOAP Simple Object-Access Protocol
16
16 What is SOAP? SOAP is a protocol for accessing Web Services SOAP is XML based –Thus, SOAP provides interoperability In SOAP applications exchange information over HTTP –Thus, SOAP is not restricted by firewalls SOAP allows to exchange structured and typed information on the Web –XSchema types are used to add types to XML SOAP specification: http://www.w3.org/TR/soap http://www.w3.org/TR/soap
17
17 A SOAP Message A SOAP message is an ordinary XML document containing the following elements: –Envelope – identifies the XML document as a SOAP message: required –Header – contains header information: optional –Body – contains call or response information: required –Fault – provides information about errors that occurred while processing the message: optional
18
18 Lisa SOAP Simplification (1) Consider the Java interface: Suppose that a client wants to call the server's sayHelloTo method Could send an XML message: Name of the InterfaceName of the MethodName of the Parameter public interface Hello { public String sayHelloTo(String name); }
19
19 SOAP Simplification (2) The Server could respond with: Hello Lisa, How are you? Name of the Interface Name of the Method + Response Returned Value
20
20 SOAP Intuition
21
21 Skeleton SOAP Message.................. A SOAP envelope must be Associated with this name space Envelope Header Body Fault
22
22 encodingStyle Attribute “The SOAP encodingStyle attribute indicates the encoding rules used to serialize parts of a SOAP message” –Needed when sending data structures This attribute may appear on any SOAP element, and it will apply to that element's contents and all child elements A SOAP message has no default encoding –Unencoded data may be used in SOAP messages The SOAP specification defines encoding rules that are identified by the URI http://www.w3.org/2002/06/soap-encoding –Other encoding rules may be used
23
23 Envelope Actual Soap Request <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Lisa
24
24 Name Spaces Actual Soap Request <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Lisa
25
25 Actual Soap Request Header Body <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Lisa
26
26 Actual Soap Request <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Lisa Interface Method Parameter
27
27 Envelope Actual Soap Response <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Hello Lisa, How are you doing?
28
28 Actual Soap Response Body <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Hello Lisa, How are you doing?
29
29 Actual Soap Response <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> Hello Lisa, How are you doing? Method Interface Returned Value
30
30 SOAP Header Element The SOAP Header element is optional It contains application specific information (like authentication, payment, etc) about the SOAP message If the Header element is present, it must be the first child element of the Envelope element Attributes that the namespace defines: –Actor – used to address the Header element to a particular server (e.g., proxy) on the message path through the Internet –mustUnderstand – used to indicate whether a header entry is mandatory or optional for the recipient to process –encodingStyle – as explained before
31
31 SOAP Header Element Example: <t:Transaction xmlns:t="some-URI" SOAP-ENV:mustUnderstand="1">5 5 is the transaction ID of which this method is a part In the above example, the SOAP-envelope attribute mustUnderstand is set to 1, which means that the server must either understand and honor the transaction request or must fail to process the message
32
32 SOAP Response on Error There can be many errors in processing a SOAP request Error in Running Method: For example, suppose that the "Hello Server" does not allow anyone to say hello on Tuesday Error in Processing SOAP Headers: For example, problem running method as part of a transaction
33
33 The Fault Element May Include the Following Sub-Elements : A code for identifying the fault : A human readable explanation of the fault : Information about who caused the fault : Holds application-specific error information related to the Body element of the SOAP request
34
34 SOAP Fault Codes VersionMismatch: Found an invalid namespace for the SOAP Envelope element MustUnderstand: An immediate child element of the Header element, with the mustUnderstand attribute set to 1, was not understood Client: The message was incorrectly formed or contained incorrect information Server: There was a problem with the server so the message could not proceed
35
35 SOAP Error Response for Method Error SOAP-ENV:Server Server Error Sorry, I cannot say hello on Tuesday. 1001
36
36 SOAP Error Response for Header Error SOAP-ENV:MustUnderstand SOAP Must Understand Error No detail element may appear when there is an error in processing the Headers of a SOAP request
37
37 Sending a Request The SOAP request does not contain the address to which it should be sent Q: Where do we put the URL of the Web Service? A: It depends on the Protocol used to send the request (usually HTTP, but could also be another protocol, e.g., SMTP)
38
38 SOAP Request via HTTP POST http://www.Hello.com/HelloApplication HTTP/1.0 Content-Type: text/xml; charset=UTF-8 Content-Length: 587 SOAPAction: urn:helloApp <SOAP-ENV:Envelope … Note: There are 2 addresses (1) URL of a SOAP Server (2) URI of an application to run (this needn't correspond to an actual Internet address)
39
39 SOAPAction Header Used to indicate the intent of the SOAP HTTP request The presence and content of the SOAPAction header field can be used by servers, such as firewalls, to appropriately filter SOAP request messages in HTTP The header-field value of an empty string ("") means that the intent of the SOAP message is provided by the URL of the HTTP Request
40
40 SOAP Response via HTTP HTTP/1.0 200 OK Content-Type: text/xml; charset=UTF-8 Content-Length: 615 <SOAP-ENV:Envelope …
41
41 Example: Currency Rate There are many available Web services that you can use See http://www.xmethods.com/ for a listhttp://www.xmethods.com/ Look, in particular, at those marked "RPC" (Remote Procedure Call) To get Currency exchange, for example, you can do "telnet wwwproxy.cs.huji.ac.il 8080" and then send the following request…
42
42 POST http://services.xmethods.net:80/soap HTTP/1.0 Content-Type: text/xml Content-Length: 485 SOAPAction: "" United States Israel
43
43 HTTP/1.0 200 OK Content-Type: text/xml <n:getRateResponse xmlns:n='urn:xmethods-CurrencyExchange'> 4.521 And Here is the Response
44
44 Example - Calling Google Spelling <SOAP-ENV:Envelope xmlns:SOAP ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“http://www.w3.org/1999/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/1999/XMLSchema”> 00000000000000000000000000 britney speers
45
45 Example - Google Spelling Response <SOAP-ENV:Envelope xmlns:SOAP ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <ns1:doSpellingSuggestionResponse xmlns:ns1="urn:GoogleSearch“ SOAP- ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> britney spears
46
46 An alternative to SOAP: XML-RPC XML-RPC is similar to SOAP but simpler You just have to specify what is the method and what are the parameters See http://www.xmlrpc.com for further detailshttp://www.xmlrpc.com
47
47 XML-RPC Request Example POST /MyRPC HTTP/1.0 Host: www.cs.huji.ac.il Content-Type: text/xml Content-length: 181 Hello.sayHelloTo Lisa
48
48 XML-RPC Response Example HTTP/1.1 200 OK Connection: close Content-Length: 158 Content-Type: text/xml Date: Sun, 6 Jun 2004 10:33:08 GMT Hello Lisa
49
49 WSDL – Web Services Description Language
50
50 Describing a Web Service Need a standard way to describe a Web Service: –the methods available –their parameters –etc. WSDL is a standard for describing Web services using XML, i.e., it is a language for the green pages of UDDI WSDL specification can be found at http://www.w3.org/TR/wsdl http://www.w3.org/TR/wsdl
51
51 WSDL Can Describe What a Web service can do Where it resides How to invoke it
52
52 The Two Layers of WSDL The service definition layer describes abstract properties: –data types –message types –operations –services The binding layer describes concrete properties (using SOAP, HTTP, MIME): –protocols –data formats
53
53 More on the Binding Layer WSDL defines services as collections of network endpoints or ports Endpoints are defined by binding a concrete network protocol and a concrete message format to abstract operations and messages In theory, WSDL can describe any endpoint regardless of the underlying network protocol or message format –In practice, WSDL is used with SOAP/HTTP/MIME
54
54 The Elements of WSDL Documents Types – containing XML Schema element and type definitions Message – an abstract typed definition of the data being communicated Operation – an abstract description of an action supported by the service Port Type – an abstract set of operations supported by one or more endpoints Binding – a concrete communication protocol and data format specification for a particular port type Port – a single endpoint defined as a combination of a binding and a network address Service – a collection of named ports, each associated with a binding and a network address
55
55 The Structure of a WSDL Document definition of types…. definition of a message definition of a port definition of a binding
56
56 Example General and specific namespaces
57
57 Types The element defines the data types that are used by the Web service For maximum interoperability, WSDL uses XML Schema syntax to define data types
58
58 Messages The element defines the data elements of an operation Each message can consist of one or more parts These parts are analogous to the parameters of a function call in Java
59
59 Example String sayHello(String firstName)
60
60 Port Types The element is the most important WSDL element The element is similar to a class in Java It defines the Web service, the operations that can be performed, and the messages that are involved
61
61 Example public interface HelloService { public String sayHello(String firstName); }
62
62 Operation Types We divide operations to four types: –One-way – the operation can receive a message but will not return a response (the operation includes only input) –Request-response – the operation can receive a request and will return a response (the operation includes input and output) –Solicit-response – the operation can send a request and will wait for a response (the operation includes output and input) –Notification – the operation can send a message but will not wait for a response (the operation includes only output)
63
63 Binding Using SOAP The SOAP element defines the details of the message format and protocol for each port The transport attribute defines the SOAP protocol to use (e.g., HTTP, FTP, SMTP) The style attribute of the binding can be either RPC (Remote Procedure Call) or document (document is the default)
64
64 RPC vs. Document RPC style indicates that the messages contain parameters and return values Document style indicates that the messages contain document(s) Differently from document style: –In RPC we need to clearly separate the arguments from each other –In RPC the order of parameters is important
65
65 The SOAP Binding in WSDL Selects document or rpc style Selects HTTP/SMTP/… protocol Selects encoding (typically, the SOAP encoding) Places messages parts in header or body parts of the envelope
66
66
67
67 A Service Description in WSDL (defining an endpoint) WSDL File for HelloService The location attribute associates the binding with a URL The location attribute associates the binding with a URL
68
68 Recall Currency Exchange Example POST http://services.xmethods.net:80/soap HTTP/1.0 Content-Type: text/xml Content-Length: 485 SOAPAction: "" United States Israel
69
69 CurrencyExchange's WSDL Next is the WSDL for this service Note that it has to describe: –URL –URI –Method Name –Method Namespace –Parameter Names –Parameter Types –Encoding of Parameters
70
70 <definitions name="CurrencyExchangeService" targetNamespace="http://www.xmethods.net/sd/CurrencyExchange Service.wsdl" xmlns:tns="http://www.xmethods.net/sd/CurrencyExchangeService. wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
71
71 <binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
72
72 <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> Returns the exchange rate <port name="CurrencyExchangePort" binding="tns:CurrencyExchangeBinding"> <soap:address location="http://services.xmethods.net:80/soap"/>
73
73 UDDI – Universal Description, Discovery and Integration
74
74 A Telephone Book How can you find a Web service? How can you register your Web service so that others will find it? UDDI is a standard for publishing and finding Web services Think of UDDI as a telephone book
75
75 How Does UDDI Work? UDDI Business Registry Service Type Registrations Business Registrations UDDI assigns a universally unique identifier (UUID) to each registry record Businesses populate the registry with descriptions of the services they support Businesses use this data to facilitate easier integration with each other over the Web Marketplaces, search engines and business apps query the registry to discover services at other companies Software companies, standards bodies and programmers populate the registry with descriptions of different service specifications
76
76 "Types" of Pages White Pages:White Pages: –Basic contact information, business name, address, etc. –Allow others to find you based on your identification Yellow Pages:Yellow Pages: –Describe Web services by category –Allow others to find you by category (e.g., car sales) Green Pages:Green Pages: –Technical information about supported methods of Web services
77
77 UDDI Data Model businessKey BA744ED0... 5229C64 name XMethods description Web services resource site contacts Lisa Simpson businessServices identifierBag categoryBag businessEntity tModelKey 8609C8 … D01823 keyName D-U-N-S keyValue 08-146-6849 keyedReference tModelKey 8609C8 … D01823 Name dnb-com:D-U-N-S Description Dun&Bradstreet D-U-N-S Number overviewDoc www.uddi.org/taxonomies/ UDDI_Taxonomy_tModels.htm#D-U-N-S categoryBag tModel serviceKey D59211 … 229C64 name XMethods Delayed Stock Quotes description 20-minute delayed stock quotes bindingTemplates categoryBag businessService bindingTemplate bindingKey D594A … 229C64 description SOAP binding for delayed stock quotes service accessPoint http://services.xmethods.net:80/soap tModelInstanceDetails tModelKey 0E727D … 229C64 Name Xmethods Simple Stock Quote description Simple stock quote interface overviewDoc xmethods.net/SimpleStockQuote.wsdl categoryBag tModel
78
78 UDDI Structure businessEntity - The top-level XML element (includes support for "yellow pages" taxonomies) businessService - contains descriptive business service information about a group of related technical services, including –the group name –a brief description –technical service-description information –service properties –service leasing details –category information
79
79 UDDI Structure bindingTemplate - contains data relevant for applications that need to invoke or bind to a specific Web Service tModel - Descriptions of specifications (protocols, formats, etc.) for Web services or taxonomies –its role is to represent the technical specification of the Web service, making it easier for Web-service consumers to find Web services that are compatible with a particular technical specification
80
80 Key Entities Description businessEntity Information about the entity who offers a service businessService Descriptive information about a particular family of technical offerings bindingTemplate Technical information about a service entry point tModel Description of specifications for services 0..n Bindings contain references to tModels. These references declare the interface specifications for a service.
81
81 Key Entities Example businessEntity Name: Acme Corp Desc: Purveyors of Fine Products URL: www.acme.comwww.acme.com Contact: Joseph Cohen businessService Name: getPrice Desc: Accepts ACME product ID as a string. Returns product price as a double. bindingTemplate Access Point: http://soap.acme.com/getPrice Desc: SOAP endpoint for the getPrice service. publisherAssertion From Key: Acme Corp. To Key: Nadir Corp. tModel Name: getPrice Desc: WSDL for the getPrice service Overview Doc: http://soap.acme.com/getPrice/wsdl category wsdlSpec identifier E1-AA-09-F3
82
82 Categorizing Entities businessEntity Name: Acme Corp Desc: Purveyors of Fine Products URL: www.acme.comwww.acme.com Contact: Joseph Cohen businessService Name: getPrice Desc: Accepts ACME product ID as a string. Returns product price as a double. bindingTemplate Access Point: http://soap.acme.com/getPrice Desc: SOAP endpoint for the getPrice service. tModel Name: getPrice Desc: WSDL for the getPrice service Overview Doc: http://soap.acme.com/getPrice/wsdl category Retail identifier DUNS: 123456 category Pricing category wsdlSpec category V 1.1 identifier E1-AA-09-F3 publisherAssertion From Key: Acme Corp. To Key: Nadir Corp.
83
83 UDDI Business Registry (UBR), Public Cloud Nodes contain all UDDI information Nodes are synchronized, so they retain the same data You can query any node You can add UDDI information to a node, and it will be replicated to all others
84
84 Registry Nodes Operation Peer-operator nodes A business can register with any node Registrations replicated on a daily basis Operates like DNS: logically centralized, physically distributed IBM Microsoft HP other queries UDDI Cloud Service client Registry Node
85
85 Interacting with the UDDI UDDI is itself a Web service!!! Interaction is via SOAP messages The JAXR package defines a standard way to interact with registries (can work with other types of registries too, e.g., ebXML) Two types of interaction: –Inquiry: Does not need authentification –Publish: Needs authentification Here is a Web interface for a UBR nodeHere
86
86 JAXR Java API used to access registries that conform to standards, such as UDDI Part of Java WSDP Taken from http://developer.java.sun.com/developer/technicalArticles/WebServices/WSPack/
87
87 UDDI API Inquiry APIPublishing API delete_business delete_service delete_binding delete_tmodel delete_business delete_service delete_binding delete_tmodel find_business find_service find_binding find_tmodel find_business find_service find_binding find_tmodel get_businessDetail get_serviceDetail get_bindingDetail get_tmodelDetail get_businessDetail get_serviceDetail get_bindingDetail get_tmodelDetail save_business save_service save_binding save_tmodel save_business save_service save_binding save_tmodel get_authtoken discard_authtoken get_authtoken discard_authtoken
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.