SOAP and Web Services
Using SOAP and Web Services
15
In the case of synchronous requests such as this one, the value returned by the
request
method (
response
in this example) is an object containing the result of the web method,
which will be one of the Acrobat JavaScript types corresponding to XSD types. The default
format for the response value is an object describing the SOAP body (or header) of the
returned message.
N
OTE
:
In the case of base64 or hex encoding of binary information, the type returned will
be a
readStream
object.
We may now obtain the returned value by using syntax that corresponds to the SOAP body
sent back by the web method:
var responseString = "http://mydomain/methods:echoStringResponse";
var result = response[responseString]["return"];
// Display the response in the console:
console.println("Result is " + result);
Similarly, we can invoke the
echoInteger
method. To do this, we will use the same value
for the
cURL
and
cAction
parameters, and develop an
oRequest
parameter like the
one we used for the
echoString
method. In this case, however, we must supply an XSD-
compliant object to represent the integer value:
var myIntegerObject = {
soapType: "xsd:int",
soapValue: "10"
};
var echoIntegerRequest = {
"http://mydomain/methods:echoInteger {
inputInteger: myIntegerObject
}
};
Now we may invoke the
echoInteger
web method and display its results:
var response = SOAP.request ({
cURL: myURL,
oRequest: echoIntegerRequest,
cAction: mySOAPAction
});
var responseString = "http://mydomain/methods:echoIntegerResponse";
var result = response[responseString]["return"];
// Display the response in the console:
console.println("Result is " + result);
Acrobat JavaScript Scripting Guide
249