Java Reference
In-Depth Information
<soap:Envelope xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"
>
<soap:Body>
<GetQuoteResponse xmlns="
http://www.webserviceX.NET/">
<GetQuoteResult>string</GetQuoteResult>
</GetQuoteResponse>
</soap:Body>
</soap:Envelope>
So now you know you can expect a SOAP reply message with a
GetQuoteResponse
tag con-
taining one internal tag—
GetQuoteResult—
which you can parse in your program.
7.
Finally, note that the web service also provides a WSDL file, which you will see later on in a bit
more depth.
How It Works
Here's how it works:
1.
is the stock quote provider.
2.
Each SOAP service provides a number of “operations.” Think of these as “methods” you can call
on the service. In the case of the stock quote provider, only one operation is provided:
GetQuote
.
3.
SOAP requests can be sent to invoke a service operation. To do so, a request message needs to
be constructed that will be sent to the service URI (the endpoint). That method must contain a
SOAPAction
header with the operation you want to call and a message body containing the param-
eters you want to send to the operation handler. The
WebserviceX.NET
websites provides example
messages for each of its operations.
4.
If the request succeeds, you know you will receive a reply formatted to the specifications as shown
on the example page. You know you can expect a SOAP reply message with a
GetQuoteResponse
tag containing one internal tag:
GetQuoteResult
. This tag contains a “string”—you can't be sure
yet how this string is formatted or what information it contains, so you'll need to take a closer look
at it once you receive SOAP replies in your program.
It's time to get started and see how you can access this service in Java. Create a class called
ClientWithoutWSDL
to do so. From the example in the Try It Out, you know that you will need the
following to access the web service:
➤
➤
The “endpoint” to which you should send the request using HTTP. For the “Stock Quote”
web service, this is
/stockquote.asmx
. Together with the hostname, this forms the full end-
➤
The name of the operation you want to invoke. In this case, this is
GetQuote
. The name of
Search WWH ::
Custom Search