Java Reference
In-Depth Information
In the next two sections, you will see how to use the Pig Latin server to translate “Hello
World” into Pig Latin. You will be shown both the request and response for this operation.
Finally, you will be shown how to use AXIS to generate Java classes that perform all of these
operations for you.
SOAP Requests
SOAP requests and responses work very similar to Java method calls. For the Pig Latin
server, think of it as calling a very simple function, such as this:
public String translate(String str);
The translate function accepts a string, which is the text to be translated, then re-
turns a translated string. To accomplish this, an XML request is built according to the SOAP
specification that contains the name of the function to call, as well as the text to translate.
Listing 11.2 shows how to call the translate function with the text “Hello World”.
Listing 11.2: Pig Latin SOAP Request
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://www.httprecipes.com/1/11/soap/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<mns:translate
xmlns:mns="http://www.httprecipes.com/1/11/soap/"
SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<inputString xsi:type="xsd:string">Hello World</inputString>
</mns:translate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
There is considerable overhead XML that tells the SOAP server what kind of request this
is; however, you can still see the function name (translate) and the text passed to the function
(Hello World).
SOAP Responses
Once the SOAP server receives the request, the text is translated and returned. The text
is returned as a SOAP formatted response. The response is seen in Listing 11.3.
Search WWH ::




Custom Search