SOAP and Web Services
Using SOAP and Web Services
15
MTOM is used by additionally setting the
request
method’s
bEncoded
parameter to
false
and the
cNamespace
parameter to an appropriate value. This is illustrated in the
following code, which creates an
oRequest
object:
// Use the MTOM standard:
var MTOMRequest = {
"echoAttachmentDL": {
dh:
{
inclusion:
{
soapAttachment: true,
soapValue: myStream
}
}
}
};
var response = SOAP.request({
cURL: myURL,
oRequest: MTOMRequest,
bEncoded: false,
cNamespace: myNamespace
});
Converting Between String and ReadStream Information
The
SOAP
object’s
streamFromString
and
stringFromStream
methods are useful
for converting between formats. The
streamFromString
method is useful for
submitting data in a web service call, and the
stringFromStream
method is useful for
examining the contents of a response returned by a web service call. An example is shown
below:
// Create a ReadStream object from an XML string:
var myStream = streamFromString("<mom name = 'Mary'></mom>");
// Place the information in an attachment:
this.setDataObjectContents("org.xml", myStream);
// Convert the ReadStream object back to a string and display in console:
console.println(stringFromStream(myStream));
Acrobat JavaScript Scripting Guide
253