Hi,
here is an example how you can create SWA with GatewayScript. Hope it is something that you can use.
var hm = require('header-metadata');
session.input.readAsBuffer(function (error, buffer) {
if (error)
{
// handle error
session.output.write (error.errorMessage);
} else {
//Create a boundary id, make sure that it isn't present in the payload
var boundary = "xyz123";
//Line break
var crlf = '\r\n';
//Create a soap message payload
var soap_message = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><foo>the soap message body part goes here</foo></soapenv:Body></soapenv:Envelope>';
//Create the multipart message payload
var multipart = '--' + boundary + crlf +
'Content-Type: text/xml' + crlf + crlf +
soap_message + crlf + '--' + boundary + crlf +
'Content-Type: text/plain' + crlf +
'Content-Transfer-Encoding: base64' + crlf +
'Content-ID: <my attachment>' + crlf + crlf +
buffer.toString('base64') + crlf + '--' + boundary + '--' + crlf;
//Concatenate a new content-type header value
var contentType = 'multipart/related; boundary=' + boundary + ' type="text/xml"';
//Set the content type header created above
hm.current.set('Content-Type', contentType);
//Write payload into output
session.output.write(multipart);
}
});
#DataPower#Support#SupportMigration