I am connecting to a WSLD SOAP service where it is necessary to use MTOM to send attached information, I am trying to upload a ZIP file in base64 but the server returns the error that it cannot find the information of the message, that is, of the attachment, then I will indicate what that I send to the server using cURL in PHP to see if someone can guide me in what I am sending wrong that does not allow the server to read the attached document.
Error Message: Could not create message from InputStream: Unable to internalize message; nested exception is com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
POST /ruta/portal.wsdl HTTP/1.1
Host: empresa.com
Accept: */*
User-Agent: PHP-7
Content-Type: multipart/related; type="application/xop+xml"; start="<[email protected]>"; start-info="text/xml"; boundary="------=_Part_1_363f118.a4e1f4f9730a01986d6c6fb8e9663303"
Content-Length: 28908
Expect: 100-continue
------=_Part_1_363f118.a4e1f4f9730a01986d6c6fb8e9663303
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <[email protected]>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rep="http://www.empresa.com/ruta/EnvioDocumentos">
<soapenv:Header>
<wsse:Security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:id="UsernameToken-2">
<wsse:Username>xxxxxxxxx</wsse:Username>
<wsse:Password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile1.0#PasswordText">xxxxx</wsse:Password>
<wsse:Nonce encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security1.0#Base64Binary">zzzzzzzzzz</wsse:Nonce>
<wsu:Created>2019-02-19T16:07:47.000Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<rep:EnvioDocumento>
<rep:Document><inc:Include href="cid:363f118a4e1f4f9730a01986d6c6fb8e96633032" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></rep:Document>
</rep:EnvioDocumento>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_1_363f118.a4e1f4f9730a01986d6c6fb8e9663303
Content-Type: application/zip; name="archivo_003a699d00.zip"
Content-Transfer-Encoding: base64
Content-ID: <363f118a4e1f4f9730a01986d6c6fb8e96633032>
Content-Disposition: attachment; name="archivo_003a699d00.zip" filename="archivo_003a699d00.zip"
UEsD....Datos_en_Base64.....zA3
------=_Part_1_363f118.a4e1f4f9730a01986d6c6fb8e9663303--
Solved, my error was in the way of using the boundary interesting data and what makes a big difference is that when you use attachments and the parts are being accessed by boundary tags you should declare the tag with "X" name and then when declaring it in the body of the message you should name the label but put two hyphens (--) before it.
The boundary mentioned in the header must be ----=_Part_1 (four hyphens) and in the message body it must go ------=_Part_1 (two extra hyphens).
Fixed example:
Example: