Representation and Management of Data on the Web Web Services Representation and Management of Data on the Web
loosely coupled software components Internet standard technologies." "Web services are loosely coupled software components delivered over Internet standard technologies."
Get Online Information Example Scenario: Get Online Information Get Stock Price Return Stock Price Stock Broker Application Get Stock Price Return Stock Price Stock Exchange
Example Scenario – Online Trade The Hobbit (5) Price: 20.95 Copies in Stock: 4 Price: 25.95 Copies in Stock: 1 Book Store The Hobbit (5) Price: 20.95 Copies in Stock: 5 Buy The Hobbit (5) How Much? Buy it Book Store The Hobbit (5) Price: 25.95 Copies in Stock: 0 Buy The Hobbit (5) 20.95 The Hobbit (5) Price: 25.95 Copies in Stock: 0 The Hobbit (5) Price: 25.95 Copies in Stock: 1
Example Scenario: Grid Computation Using seamlessly the combined resources of many computers that are connected to the Internet
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
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?
How can we find this URL? What is the price here?
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
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?
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
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.
Implementing Web Services Programmers are given tools that spare the need to directly write 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
SOAP Simple Object-Access Protocol
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/2000/xp/Group/
A request to http://services.xmethods.net:80/soap POST /soap HTTP/1.0 SOAPAction: "" Content-Length: 520 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:getRate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:xmethods-CurrencyExchange"> <country1 xsi:type="xsd:string">Euro</country1> <country2 xsi:type="xsd:string">Israel</country2> </ns1:getRate> </soapenv:Body> </soapenv:Envelope> A request to http://services.xmethods.net:80/soap
The Response HTTP/1.0 200 OK Date: Sat, 07 May 2005 23:26:21 GMT Content-Length: 492 Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?> <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> <soap:Body> <n:getRateResponse xmlns:n='urn:xmethods-CurrencyExchange'> <Result xsi:type='xsd:float'>5.5825</Result> </n:getRateResponse> </soap:Body> </soap:Envelope> The Response
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
SOAP Simplification (1) Consider the Java interface: Suppose that a client wants to call the server's sayHelloTo method Could send an XML message: public interface Hello { public String sayHelloTo(String name); } <?xml version="1.0"?> <Hello> <sayHelloTo> <name>Lisa</name> </sayHelloTo> </Hello> Name of the Interface Name of the Method Name of the Parameter
SOAP Simplification (2) The Server could respond with: <?xml version="1.0"?> <Hello> <sayHelloToResponse> <message>Hello Lisa, How are you?</message> </sayHelloToResponse> </Hello> Name of the Interface Returned Value Name of the Method + Response
SOAP Intuition
Skeleton SOAP Message A SOAP envelope must be <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Header> ... ... </soap:Header> <soap:Body> <soap:Fault> </soap:Fault> </soap:Body> </soap:Envelope> A SOAP envelope must be Associated with this name space Envelope Header Body Fault
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 content and all child elements A SOAP message has no default encoding Unencoded data may be used in SOAP messages The SOAP default XMLSchema for SOAP encoding and data types is: http://www.w3.org/2002/12/soap-encoding Other encoding rules may be used
Actual Soap Request Envelope <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"> <SOAP-ENV:Header> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <name xsi:type="xsd:string">Lisa</name> </ns1:sayHelloTo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Envelope
Actual Soap Request Name Spaces <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"> <SOAP-ENV:Header> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <name xsi:type="xsd:string">Lisa</name> </ns1:sayHelloTo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Name Spaces
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"> <SOAP-ENV:Header> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <name xsi:type="xsd:string">Lisa</name> </ns1:sayHelloTo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Header Body
Actual Soap Request Interface Method Parameter <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"> <SOAP-ENV:Header> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:sayHelloTo xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <name xsi:type="xsd:string">Lisa</name> </ns1:sayHelloTo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Interface Method Parameter
Actual Soap Response Envelope <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"> <SOAP-ENV:Body> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string"> Hello Lisa, How are you doing? </return> </ns1:sayHelloToResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
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"> <SOAP-ENV:Body> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string"> Hello Lisa, How are you doing? </return> </ns1:sayHelloToResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Body
Actual Soap Response Method Interface Returned Value <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"> <SOAP-ENV:Body> <ns1:sayHelloToResponse xmlns:ns1="Hello" SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string"> Hello Lisa, How are you doing? </return> </ns1:sayHelloToResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Method Interface Returned Value
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
SOAP Header Element Example: <SOAP-ENV:Header> <t:Transaction xmlns:t="some-URI" SOAP-ENV:mustUnderstand="1">5 </t:Transaction> </SOAP-ENV:Header> 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
SOAP Response on Error There can be many errors in processing a SOAP request Error in Running Methods: For example, suppose that the "Hello Server" does not allow anyone to say hello on Tuesday Error in Processing SOAP Headers: For example, a problem running the method as part of a transaction
The Fault Element May Include the Following Sub-Elements <faultcode> : A code for identifying the fault <faultstring> : A human readable explanation of the fault <faultactor> : Information about who caused the fault <detail> : Holds application-specific error information related to the Body element of the SOAP request
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
SOAP Error Response for Method Error <SOAP-ENV:Envelope xmlns:SOAP-ENV=" http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Server Error</faultstring> <detail> <e:myfaultdetails xmlns:e="Hello"> <message> Sorry, I cannot say hello on Tuesday. </message> <errorcode>1001</errorcode> </e:myfaultdetails> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Error Response for Header Error <SOAP-ENV:Envelope xmlns:SOAP-ENV=" http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:MustUnderstand</faultcode> <faultstring>SOAP Must Understand Error</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope> No detail element may appear when there is an error in processing the Headers of a SOAP request
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)
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)
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
SOAP Response via HTTP HTTP/1.0 200 OK Content-Type: text/xml; charset=UTF-8 Content-Length: 615 <SOAP-ENV:Envelope …
Example: Currency Rate There are many available Web services that you can use See http://www.xmethods.com/ for a list 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…
POST http://services.xmethods.net:80/soap HTTP/1.0 Content-Type: text/xml Content-Length: 485 SOAPAction: "" <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"> <SOAP-ENV:Body> <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <country1 xsi:type="xsd:string">United States</country1> <country2 xsi:type="xsd:string">Israel</country2> </ns1:getRate> </SOAP-ENV:Body></SOAP-ENV:Envelope>
And Here is the Response HTTP/1.0 200 OK Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?> <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' xmlns:xsd='http://www.w3.org/1999/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> <soap:Body><n:getRateResponse xmlns:n='urn:xmethods-CurrencyExchange'> <Result xsi:type='xsd:float'>4.521</Result> </n:getRateResponse> </soap:Body></soap:Envelope>
Example - Calling Google Spelling <?xml version="1.0" encoding="UTF-8" ?> <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”> <SOAP-ENV:Body> <ns1:doSpellingSuggestion xmlns:ns1=“urn:GoogleSearch” SOAP- ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <key xsi:type="xsd:string">00000000000000000000000000</key> <phrase xsi:type="xsd:string">britney speers</phrase> </ns1:doSpellingSuggestion> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Example - Google Spelling Response <?xml version="1.0" encoding="UTF-8" ?> <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"> <SOAP-ENV:Body> <ns1:doSpellingSuggestionResponse xmlns:ns1="urn:GoogleSearch“ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string">britney spears</return> </ns1:doSpellingSuggestionResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
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 details
XML-RPC Request Example POST /MyRPC HTTP/1.0 Host: www.cs.huji.ac.il Content-Type: text/xml Content-length: 181 <?xml version="1.0"?> <methodCall> <methodName>Hello.sayHelloTo</methodName> <params> <param> <value><string>Lisa</string></value> </param> </params> </methodCall>
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 <?xml version="1.0"?> <methodResponse> <params> <param> <value><string>Hello Lisa</string></value> </param> </params> </methodResponse>
Example 1: MD5 Transform
Example 2: Baghdad Weather
Example 2: Baghdad Weather
Example 3: World Cities
Example 3: World Cities
WSDL – Web Services Description Language
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
WSDL Can Describe What a Web service can do Where it resides How to invoke it
<definitions name="CurrencyExchangeService" <?xml version="1.0"?> <definitions name="CurrencyExchangeService" targetNamespace="http://www.xmethods.net/sd/CurrencyExchangeService.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/"> <message name="getRateRequest"> <part name="country1" type="xsd:string"/> <part name="country2" type="xsd:string"/> </message> <message name="getRateResponse"> <part name="Result" type="xsd:float"/> <portType name="CurrencyExchangePortType"> <operation name="getRate"> <input message="tns:getRateRequest" name="getRate"/> <output message="tns:getRateResponse" name="getRateResponse"/> </operation></portType>
<service name="CurrencyExchangeService"> <binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getRate"> <soap:operation soapAction=""/> <input name="getRate"> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output name="getRateResponse"> </output> </operation> </binding> <service name="CurrencyExchangeService"> <documentation>Returns the exchange rate between the two currencies</documentation> <port name="CurrencyExchangePort" binding="tns:CurrencyExchangeBinding"> <soap:address location="http://services.xmethods.net:80/soap"/> </port> </service> </definitions>
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
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
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
The Structure of a WSDL Document <definition> <types> definition of types…. </types> <messages> definition of a message </message> <port type> definition of a port </port type> <binding> definition of a binding </binding> </definition> <definition> <types> <messages> <portType> <binding>
General and specific namespaces Example <?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloService" targetNamespace="http://www.hello.com/wsdl/HelloService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.hello.com/wsdl/HelloService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> General and specific namespaces
Types The <types> element defines the data types that are used by the Web service For maximum interoperability, WSDL uses XML Schema syntax to define data types
Messages The <message> 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
String sayHello(String firstName) Example <message name="SayHelloRequest"> <part name="firstName" type="xsd:string"/> </message> <message name="SayHelloResponse"> <part name="greeting" type="xsd:string"/> </message> String sayHello(String firstName)
Port Types The <portType> element is the most important WSDL element The <portType> 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
Example <portType name="Hello_PortType"> <operation name="sayHello"> <input message="tns:SayHelloRequest"/> <output message="tns:SayHelloResponse"/> </operation> </portType> public interface HelloService { public String sayHello(String firstName); }
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)
Binding Using SOAP The SOAP <binding> 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)
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
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
<binding name="Hello_Binding" type="tns:Hello_PortType"> <soap:binding style="rpc“ transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="sayHello"> <soap:operation soapAction="sayHello"/> <input> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:helloservice" use="encoded"/> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:helloservice" use="encoded"/> </output> </operation> </binding>
A Service Description in WSDL (defining an endpoint) <service name="Hello_Service"> <documentation>WSDL File for HelloService</documentation> <port binding="tns:Hello_Binding" name="Hello_Port"> <soap:address location="http://pita:8080/soap/servlet/myService"/> </port> </service> </definitions> The location attribute associates the binding with a URL
Recall Currency Exchange Example POST http://services.xmethods.net:80/soap HTTP/1.0 Content-Type: text/xml Content-Length: 485 SOAPAction: "" <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"> <SOAP-ENV:Body> <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <country1 xsi:type="xsd:string">United States</country1> <country2 xsi:type="xsd:string">Israel</country2> </ns1:getRate></SOAP-ENV:Body></SOAP-ENV:Envelope> Recall Currency Exchange Example
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
<?xml version="1.0"?> <definitions name="CurrencyExchangeService" targetNamespace="http://www.xmethods.net/sd/CurrencyExchangeService.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/"> <message name="getRateRequest"> <part name="country1" type="xsd:string"/> <part name="country2" type="xsd:string"/> </message> <message name="getRateResponse"> <part name="Result" type="xsd:float"/>
<portType name="CurrencyExchangePortType"> <operation name="getRate"> <input message="tns:getRateRequest" /> <output message="tns:getRateResponse" /> </operation> </portType> <binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <soap:operation soapAction=""/> <input > <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input>
<output > <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="CurrencyExchangeService"> <documentation>Returns the exchange rate </documentation> <port name="CurrencyExchangePort" binding="tns:CurrencyExchangeBinding"> <soap:address location="http://services.xmethods.net:80/soap"/> </port> </service></definitions>
UDDI – Universal Description, Discovery and Integration
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
Business Registrations How Does UDDI Work? Software companies, standards bodies and programmers populate the registry with descriptions of different service specifications Marketplaces, search engines and business apps query the registry to discover services at other companies UDDI Business Registry Businesses use this data to facilitate easier integration with each other over the Web Business Registrations Service Type Registrations Businesses populate the registry with descriptions of the services they support UDDI assigns a universally unique identifier (UUID) to each registry record
"Types" of Pages White Pages: Yellow Pages: Green Pages: Basic contact information, business name, address, etc. Allow others to find you based on your identification Yellow Pages: Describe Web services by category Allow others to find you by category (e.g., car sales) Green Pages: Technical information about supported methods of Web services
UDDI Data Model businessEntity keyedReference tModel businessService 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 serviceKey D59211 … 229C64 name XMethods Delayed Stock Quotes description 20-minute delayed stock quotes bindingTemplates categoryBag businessService 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 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
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
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
Key Entities Description businessEntity Information about the entity who offers a service Bindings contain references to tModels. These references declare the interface specifications for a service. 0..n businessService Descriptive information about a particular family of technical offerings 0..n bindingTemplate Technical information about a service entry point tModel Description of specifications for services 0..n
Key Entities Example businessEntity publisherAssertion businessService Name: Acme Corp Desc: Purveyors of Fine Products URL: www.acme.com Contact: Joseph Cohen publisherAssertion From Key: Acme Corp. To Key: Nadir Corp. 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 wsdlSpec identifier E1-AA-09-F3
Categorizing Entities businessEntity Name: Acme Corp Desc: Purveyors of Fine Products URL: www.acme.com Contact: Joseph Cohen category Retail publisherAssertion From Key: Acme Corp. To Key: Nadir Corp. identifier DUNS: 123456 businessService Name: getPrice Desc: Accepts ACME product ID as a string. Returns product price as a double. category Pricing bindingTemplate Access Point: http://soap.acme.com/getPrice Desc: SOAP endpoint for the getPrice service. category V 1.1 tModel Name: getPrice Desc: WSDL for the getPrice service Overview Doc: http://soap.acme.com/getPrice/wsdl category wsdlSpec identifier E1-AA-09-F3
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
Registry Nodes Operation IBM Microsoft HP other queries UDDI Cloud Service client Registry Node Peer-operator nodes A business can register with any node Registrations replicated on a daily basis Operates like DNS: logically centralized, physically distributed
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 node
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/
UDDI API Inquiry API Publishing API find_business find_service find_binding find_tmodel save_business save_service save_binding save_tmodel get_businessDetail get_serviceDetail get_bindingDetail get_tmodelDetail delete_business delete_service delete_binding delete_tmodel get_authtoken discard_authtoken