|
Before you begin to learn WSDL, it is necessary to revisit the GetStockQuote Web Service that was discussed in the last chapter because the WSDL example in this chapter builds on this document.
In the last chapter, the Web Service received several requests for quotes and then returned several prices. For the sake of simplifying the WSDL code, the SOAP code for the example in this chapter simply receives one stock symbol and then transmits one price.
In the following code, you’ll see that the single symbol “C” (for Citicorp) resides in the code.
POST /stockquotes HTTP/1.1 Host: www.advocatemedia.com:80 Content-Type: text/xml; charset=utf-8 Content-Length: 482 SOAPAction: "http://www.advocatemedia.com/webservices/getquote" <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <env:Body> <StockQuoteRequest xmlns="http://advocatemedia.com/Examples"> <symbol xsi:type="string"> C </symbol> </StockQuoteRequest> </env:Body> </env:Envelope>
The response sends one single price back to the client. In the following example, you’ll see that the service sends the price of the stock back to the client in the form of float.
HTTP/1.1 200 OK Connection: close Content-Length: 659 Content-Type: text/xml; charset=utf-8 <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <env:Body> <StockQuoteResponse xmlns="http://advocatemedia.com/Examples" <price xsi:type="float"> 53.21 </price> </StockQuoteResponse> </env:Body> </env:Envelope>
Thus, overall the structure of the Web Service is the same. It’s just simplified for the examples in this chapter.
|