15
SOAP and Web Services
Using SOAP and Web Services
Exchanging File Attachments and Binary Data
As you learned earlier, the
oRequest
parameter provides alternative options for sending
binary-encoded data. This may be useful for sending information such as serialized object
data or embedded images. You may embed binary information in text-based format in the
SOAP envelope by using base64 encoding, or take advantage of the Soap With
Attachments
®
(SwA) standard or the Message Transmission Optimization Mechanism
®
(MTOM) to send the binary data in a more efficient format. Both SwA and MTOM can
significantly reduce network transmission time, file size, and XML parsing time.
SwA can be used by setting the
oRequest
parameter’s
soapAttachment
value to
true
, as shown in the example below. Assume
myStream
is a
readStream
object
containing binary data:
// Use the SwA standard:
var SwARequest = {
"http://mydomain/methods:echoAttachment": {
dh:
{
soapAttachment: true,
soapValue: myStream
}
}
};
var response = SOAP.request ({
cURL: myURL,
oRequest: SwARequest
});
var responseString = "http://mydomain/methods:echoAttachmentResponse";
var result = response[responseString]["return"];
252
Acrobat JavaScript Scripting Guide