Java Reference
In-Depth Information
<backslash> is read, the code enters the main loop for reading the <story> elements. Depending
on the event type, the program descends into the readStory() method for reading a story or leaves
the loop.
Simple Object Access Protocol: SOAP
The Simple Object Access Protocol (SOAP) is an XML-based protocol for remote method invocation.
The SOAP protocol allows you to access Web services such as weather forecasts, stock quotes, or
flight-booking information in a machine readable manner. Possible applications are clients adding
value by combining different related services, or providing an user interface appropriate for mobile
devices.
SOAP calls consist of a request sent from a client to a server and a response from the server. Listing
10.5 shows an example SOAP request, taken from the delayed stock quote example available at
http://www.xmethods.org . The <getQuote> element in the body of the message represents the
method to be called on the server, and the embedded symbol element contains the only method
parameter: the name of the symbol to be queried. The corresponding server response example is shown
in Listing 10.6 . The <getQuoteResponse> element contains the return value in the <return>
element.
Note
The XMethods Web site ( http://www.xmethods.org ) also provides a nice overview of SOAP resources
available on the Net.
Listing 10.5 SampleSoapRequest.xml —Sample SOAP Stock Quote 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">
<SOAP-ENV:Body>
<ns1:getQuote
xmlns:ns1="urn:xmethods-delayed-quotes"
SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<symbol xsi:type="xsd:string">IBM</symbol>
</ns1:getQuote>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Listing 10.6 SampleSoapResponse.xml —Sample Server Response to the Stock Quote
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">
<SOAP-ENV:Body>
<ns1:getQuoteResponse
 
 
 
 
Search WWH ::




Custom Search