If your source is an XML source you can use the following function to build the message response:
function checkForMTOM(response,convertMessage) {
if (source.getNode('/Request/Part/content-type').contains('xop+xml')) {
// convert to MTOM response
var boundary = qie.getUUID(true);
var responseM = qie.parseXMLString(response);
response = 'Content-Type: multipart/related;' +
'type="application/xop+xml";' +
'boundary="' + boundary + '";' +
'start="<root.message@cxf.apache.org>";' +
'start-info="application/soap+xml";' +
'action="' + responseM.getNode('/Envelope/Header/Action') + '"\r\n' +
'\r\n' +
'--' + boundary + '\r\n' +
'Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"\r\n' +
//'Content-Type: application/soap+xml\r\n' +
'Content-Transfer-Encoding: binary\r\n' +
'Content-ID: <root.message@cxf.apache.org>\r\n' +
'\r\n' +
//qie.base64Encode(response) + '\n' +
response + '\r\n' +
'--' + boundary + '--\r\n';
if (convertMessage) {
message = qie.createTextMessage();
}
}
return response;
}