Web Services - Procedures.
On this page, we show how the web services are used in order to discover, describe and use a web service. As an example, we use the Delayed Stock Quote service provided by XMethods.
Discovery
Web service clients use web service registries to discover the available web services. There are several web service registries on the Internet. Registries are operated by IBM and Microsoft. In our examples, we use the Microsoft registry, which is accessed via the URL: http://uddi.microsoft.com/inquire.
The client wishes to use the Delayed Stock Quotes service provided by XMethods. In order to discover the service, sends a UDDI message to the registry, requesting details about the XMethods services.
<?xml version="1.0" encoding="UTF-8" ?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <find_business xmlns="urn:uddi-org:api" generic="1.0" maxRows="100"> <findQualifiers /> <name>XMethods</name> </find_business> </Body> </Envelope>
The message contains a request for an execution of the find_business method on the registry server. The parameters to the method include the business being requested, in our case XMethods.
The registry returns a BusinessList object. The BusinessList contains a single element, this lists the services provided by XMethods.
<?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"> <soap:Body> <businessList generic="1.0" operator="Microsoft Corporation" truncated="false" xmlns="urn:uddi-org:api"> <businessInfos> <businessInfo businessKey="ba744ed0-3aaf-11d5-80dc002035229c64"> <name> XMethods </name> <description xml:lang="en"> Web services resource site </description> <serviceInfos> <serviceInfo serviceKey="d5b180a0-4342-11d5-bd6c-002035229c64" businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"> <name> XMethods Barnes and Noble Quote </name> </serviceInfo> <serviceInfo serviceKey="ed85f000-4345-11d5-bd6c-002035229c64" businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"> <name> XMethods Pacific Bell SMS Service </name> </serviceInfo> <serviceInfo serviceKey="d5921160-3e16-11d5-98bf-002035229c64" businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"> <name> XMethods Delayed Stock Quotes </name> </serviceInfo> <serviceInfo serviceKey="618167a0-3e64-11d5-98bf-002035229c64" businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"> <name> XMethods Currency Exchange Rates </name> </serviceInfo> </serviceInfos> </businessInfo> </businessInfos> </businessList> </soap:Body> </soap:Envelope>
The response shows that XMethods provides four services:
- XMethods Barnes and Noble Quote.
- XMethods Pacific Bell SMS Service.
- XMethods Delayed Stock Quotes.
- XMethods Currency Exchange Rates.
Notice that XMethods is uniquely identified by a businessKey value and that each service is uniquely identified by a serviceKey. If the client needs to know more about the XMethods business such as contact names, phone numbers or email addresses, it could make further queries on the registry using the businessKey.
Out client needs to find out more about the Delayed Quote Service so it makes use of the serviceKey. The client invokes the get_serviceDetail method at the registry, quoting the appropriate service key (d5921160-3e16-11d5-98bf-002035229c64).
<?xml version="1.0" encoding="UTF-8" ?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <get_serviceDetail xmlns="urn:uddi-org:api" generic="1.0"> <serviceKey> d5921160-3e16-11d5-98bf-002035229c64 </serviceKey> </get_serviceDetail> </Body> </Envelope>
The registry returns a serviceDetail object that describes the XMethods Delayed Stock Quote Service.
<?xml version="1.0" encoding="utf-8" ?> <soap:Envelope xlmns:soap=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <serviceDetail generic="1.0" operator="Microsoft Corporation" truncated="false" xmlns="urn:uddi-org:api"> <businessService serviceKey="d5921160-3e16-11d5-98bf-002035229c64" businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"> <name> XMethods Delayed Stock Quotes </name> <description xml:lang="en"> 20-minute delayed stock quotes </description> <bindingTemplates> <bindingTemplate bindingKey="d594a970-3e16-11d5-98bf-002035229c64" serviceKey="d5921160-3e16-11d5-98bf-002035229c64"> <description xml:lang="en"> SOAP binding for delayed stock quotes service </description> <accessPoint URLType="http"> http://services.xmethods.net:80/soap </accessPoint> <tModelInstanceDetails> <tModelInstanceInfo tModelKey="uuid:0e727db0-3e14-11d5-98bf-002035229c64"/> </tModelInstanceDetails> </bindingTemplate> </bindingTemplates> </businessService> </serviceDetail> </soap:Body> </soap:Envelope>
The serviceDetail object contains information such as the service name and a brief description. The tModelKey uniquely identifies the technical model, the interface used by the XMethods Delayed Quote Service. The access point is the URL used to access the service (http://services.xmethod.net:80/soap).
The client could use the tModelKey to find out more about the service interface. For example, the registry can provide a list of services that make use of the model. So we could discover other stock quote services, providing data from other financial exchanges. Using our train operator example, we could discover a list of services using the standardised timetable and pricing information.
The client can find out more about a particular model by sending a message to the registry that requests execution of the get_tModelDetail method, quoting the tModelKey.
<?xml version="1.0" encoding="UTF-8" ?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <get_tModelDetail xmlns="urn:uddi-org:api" generic="1.0"> <tModelKey> uuid:0e727db0-3e14-11d5-98bf-002035229c64 </tModelKey> get_tModelDetail> </Body> </Envelope>
The registry server replies with a tModelDetail object.
<?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"> <soap:Body> <tModelDetail generic="1.0" operator="Microsoft Corporation" truncated="false" xmlns="urn:uddi-org:api"> <tModel tModelKey="uuid:0e727db0-3e14-11d5-98bf-002035229c64" operator="www.ibm.com/services/uddi" authorizedName="0100001QS1"> <name> XMethods Simple Stock Quote </name> <description xml:lang="en"> Simple stock quote interface </description> <overviewDoc> <description xml:lang="en"> wsdl link </description> <overviewURL> http://www.xmethods.net/tmodels/SimpleStokeQuote.wsdl </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="uuid:c1acf26d-9672-4404-9d70-39b756e62ab4" keyName="uddi-org:types" keyValue="wsdlSpec" /> </categoryBag> </tModel> </tModelDetail> </soap:Body> </soap:Envelope>
The tModelDetail object contains an overViewURL object. This is the URL of a WSDL document. It describes the client/server interface for the XMethods Delayed Stock Quotes service.
Description
The discovery procedures have allowed a client to search a directory of web services for the service he requires. It has given him the service access point, the web address of the service. It has also given him the location of a WSDL file that describes service interface.
A simple HTTP GET request will provide the WSDL file. The file contains:
<?xml version = "1.0"?> <definitions name = "XMethods Simple Stock Quotes" targetNamespace = "http://www.xmethods.net/tmodels/SimpleStockQuotes.wsdl" xmlns:tns = "http://www.xmethods.net/tmodels/SimpleStockQuotes.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 = "getQuoteRequest"> <part name = "symbol" type = "xsd:string"/> </message> <message name = "getQuoteResponse"> <part name = "Result" type = "xsd:float"/> </message> <portType name = "StockQuotePortType"> <operation name = "getQuote"> <input message = "tns:getQuoteRequest" /> <output message = "tns:getQuoteResponse" /> </operation> </portType> <binding name = "StockQuoteBinding" type = "tns:StockQuotePortType"> <soap:binding style = "rpc" transport = "http://schemas.xmlsoap.org/soap/http"/> <operation name = "getQuote"> <soap:operation soapAction="http://xmethods.net/SimpleStockQuote/#getQuote"/> <input> <soap:body use = "encoded" namespace = "http://xmethods.net/SimpleStockQuote/" encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use = "encoded" namespace = "http://xmethods.net/SimpleStockQuote/" encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> </definitions>
The WSDL file for the XMethods Stock Quote service describes two messages. The getQuoteRequest message contains a stock symbol parameter. The getQuoteResponse message contains a result value. The getQuote operation consists of a getQuoteRequest/ getQuoteResponse message exchange between the client and the server. The symbol value in the request identifies the stock to be queried. The result value in the response is the price of the stock identified by the symbol.
Invocation
The discovery procedures have allowed a client to search a directory of web services for the service he requires. It has given him the service access point, the web address of the service.
The discovery procedures have described the interface that client should use in order to make use of the service.
In order to use the service the client composes a getQuoteRequest as shown below. He sends the request to the service at the access point obtained by the discovery process, that is http://services.xmethods.net:80/soap. In this example, the client is requesting the price of Riverstone Networks’ stock, identified by the symbol: RSTN.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns= "http://www.xmethods.net/tmodels/SimpleStockQuotes.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <mns:getQuote xmlns:mns="http://xmethods.net/SimpleStockQuote/" SOAP-ENV:encodingStyle ="http://schemas.xmlsoap.org/soap/encoding/"> <symbol xsi:type="xsd:string"> RSTN </symbol> </mns:getQuote> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
The price of Riverstone Networks’ stock is $2.26. The server returns this information as the Result in a getQuoteResponse.
<?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:getQuoteResponse xmlns:n="http://xmethods.net/SimpleStockQuote/"> <Result xsi:type="xsd:float"> 2.26 </Result> </n:getQuoteResponse> </soap:Body> </soap:Envelope>
Client Development
The previous sub-sections show how clients can send XML messages to the web service registries in order to discover web services. The registries currently provided by IBM and Microsoft also have web browser interfaces. This means that a developer of client software can query the registries without having to write the code to generate the registry requests and parse the responses.
The first step in writing client software might be to write a simple client that communicates with only one server. The software developer would use a web browser to discover the server, make a note of the access point and study the WSDL description. He would configure and code these details into the new client.
A more sophisticated client might respond to any problems with the client/server interaction by revisiting the registry and checking whether the access point had moved or whether the service description had changed.
A fully functional client might visit the registry on a regular basis, looking for new services making use of the same interface. The client could make use of the new service immediately or inform the system administrators that a new service is available.
Server Development
Web service registries can be updated by service providers. Again both XML and browser based updates can be performed.