Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added MTOM support for binary data #1054

Merged
merged 3 commits into from Mar 27, 2019
Merged

Added MTOM support for binary data #1054

merged 3 commits into from Mar 27, 2019

Conversation

maxime-morand
Copy link
Contributor

Added an extra option named "attachments" to send binary attachements using XOP+MTOM.
No changes has been made to XML request generation, only to the HTTP request, which become a multipart/related request containing both the SOAP request and the attachments.

For example, following request :

const args = {
  "field1": "field 1 value",
  "field2": "another value",
  "attachment": {
      "$xml": "<inc:Include href=\"cid:file_0\" xmlns:inc=\"http://www.w3.org/2004/08/xop/include\"/>"
  }
}

var options = {
  attachments: [{
    mimetype: 'image/png',
    contentId: 'file_0',
    name: 'nodejs.png',
    body: fs.createReadStream(__dirname + '/static/nodejs.png')
  }]
};

client.myFunction(args, callback, options);

will generate :

Content-Type: multipart/related; type="application/xop+xml"; start="0bfcf82f-f55e-4931-b142-05429eff684c"; start-info="text/xml"; boundary=' + uuid()

--66ce22ce-58b1-44cb-9006-accdc7ebf8e7
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-ID: <0bfcf82f-f55e-4931-b142-05429eff684c>

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <soap:Body>
  <Request xmlns="http://www.example.com/v1">
    <field1>field 1 value</field1>
    <field2>another value</field2>
    <attachment>
      <inc:Include href="cid:file_0" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
    </attachment>
  </Request>
  </soap:Body>
</soap:Envelope>

--66ce22ce-58b1-44cb-9006-accdc7ebf8e7
Content-Type: image/png
Content-Transfer-Encoding: binary
Content-ID: <file_0>
Content-Disposition: attachment; filename="nodejs.png"

<binary data>
--66ce22ce-58b1-44cb-9006-accdc7ebf8e7--

@coveralls
Copy link

coveralls commented Mar 26, 2019

Coverage Status

Coverage increased (+0.03%) to 93.273% when pulling f882494 on maxime-morand:master into 1f4af8a on vpulim:master.

@jsdevel
Copy link
Collaborator

jsdevel commented Mar 26, 2019

i'll merge this once the build is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants