SOAP and Web Services
Using SOAP and Web Services
15
// Invoke the web service:
SOAP.request({
cURL: myURL,
oRequest: echoIntegerRequest,
oAsync: mySync,
cAction: mySOAPAction
});
// The response callback function could contain the following code:
// Handle the asynchronous response:
var result = mySync.result("echoInteger");
// Display the response in the console:
console.println("Result is " + result);
Using Document/Literal Encoding
You may use document/literal encoding in your SOAP messages by assigning values to the
following parameters of the
request
method:
bEncoded
: Assign a value of
false
to this parameter.
●
cNamespace
: Specify a namespace for the message schema.
●
cResponseStyle
: Assign
SOAPMessageStyle.JS
,
SOAPMessageStyle.XML
,
or
SOAPMessageStyle.Message
value to this parameter.
Once this is done, fill the
oRequest
parameter with an object literal containing the data.
●
An example is given below:
// Set up two integer values to be added in a web method call:
var aInt = {soapType: "xsd:int", soapValue: "10"};
var bInt = {soapType: "xsd:int", soapValue: "4"};
// Set up the document literal:
var req = {};
req["Add"] = {a: aInt, b: bInt};
// Invoke the web service:
var response = SOAP.request({
cURL: myURL,
oRequest: req,
cAction: mySOAPAction,
bEncoded: false,
cNamespace: myNamespace,
cResponseStyle: SOAPMessageStyle.Message
});
// Display the response to the console:
var value = response[0].soapValue[0].soapValue;
console.println("ADD(10 + 4) = " + value);
Acrobat JavaScript Scripting Guide
251