web-serviceswebspheremtomsaajxop

In WebSphere SOAP XOP attachments references are replaced with the attachment base64 value


I am facing the following problem: when sending SAAJ requests with MTOM attachments , the original request body looks like this

<soapenv:Body>
   <ns1:UploadMsgRq>
      <ns2:Attachment><xop:Include href="cid:testfile.xml" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></ns2:Attachment>           
   </ns1:UploadMsgRq>
</soapenv:Body>>

The attachment tag value get transformed to

<ns2:Attachment>PHN0YXJ0Pkdhc3Nlcjwvc3RhcnQ+</ns2:Attachment>

which is the base64 value of my attachments, I don't want this to happen, specially that the attachment is already added as MTOM part. Also the same code is working as desired on JBOSS.

Is there a special handling that I should do n websphere?


Solution

  • Here is the solutions that I've found:

    1. Drop the SAAJ client and generate a client from the WSDL, this will automatically keep the XOP:Include as is.
    2. Keep the SAAJ Client but for the include tag you must do one of the following a) make sure that the include tag has a space in its content <xop:Include href="cid:testfile.xml" xmlns:xop="http://www.w3.org/2004/08/xop/include"> </xop:Include> or b) add it dynamically using addChildElement. For both a and b your handler -if any- shouldn't call context.getMessage() or it will generate the bas64 again.