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

Sending MTOM Attachments #185

Closed
mckaycr opened this issue Aug 29, 2018 · 10 comments
Closed

Sending MTOM Attachments #185

mckaycr opened this issue Aug 29, 2018 · 10 comments
Labels

Comments

@mckaycr
Copy link

mckaycr commented Aug 29, 2018

Description/Steps to reproduce

I'm trying to submit an MTOM attachment through the soap client, I have no idea how to accomplish it

Link to reproduction sandbox

Expected result

Some pointers or syntax that might help

Additional information

The system I'm trying to interface with

@arpentnoir
Copy link

+1
I'm in the same boat

@mckaycr
Copy link
Author

mckaycr commented Sep 26, 2018

+1
I'm in the same boat

I found a second option. The service I write too accepts files in two methods, one is a MTOM attachment, and the other is to include a files element where each file is encoded in base64 and then placed into an array. That was a lot easier than hunting down some method for attaching MTOM.

@maccyber
Copy link

maccyber commented Oct 3, 2018

Does not seem like MTOM is supported in strong-soap.

ws.js was the only library I could find that supports it, but i had to patch it to work: https://www.npmjs.com/package/ws.js-buffer-fix

It's old and fugly, but seems like the only way to go if you don't want to write it yourself.

@chrisgh1
Copy link

Interested in mtom support also. Is this on the road map? Also I'm currently using ws.js but it looks like the project may have been abandoned. I'm also having an issue with it with large files ie files in the 500MB rang and above. @maccyber I see your link has ws.js-buffer-fix could you elaborate on the "buffer fix"? I'm wondering if this would resolve my issue with the large files.

@milesje
Copy link

milesje commented May 7, 2019

I'm also interested in MTOM support for both sending and receiving!

@raymondfeng
Copy link
Contributor

raymondfeng commented May 7, 2019

Unfortunately we don't have bandwidth to implement MTOM support, but contributions are welcome!

@adi-gabrielli
Copy link

adi-gabrielli commented May 30, 2019

Node-soap has a support for sending MTOM requests via this: vpulim/node-soap#1054
On the server side there is no implementation so I had to write some middleware to handle the request. Something along these lines ( i have a gzipped file attachment here which I temporarily save to some folder and I edit the SOAP xml to hold the path to the temp file ... bullshit standard):

var multiparty = require('multiparty');
const { ungzip } = require('node-gzip');
var convert = require('xml-js');
function MOTMhandler (req, res, next){
    var response = "";
    if (req.headers["content-type"] && req.headers["content-type"].indexOf("multipart") > -1) {
        var form = new multiparty.Form({
            uploadDir: "/tmp/temp_upload"
        });
        form.parse(req, (err, fields, files) => {
            let field_key = Object.keys(fields)[0];
            let file_key = Object.keys(files)[0];
            

            var res_xml = convert.xml2js(fields[field_key][0]);

            const filedata = fs.readFileSync(files[file_key][0].path);
            ungzip(filedata)
            .then( (uncompressed) => {
                fs.writeFile(files[file_key][0].path+"_uncompressed", uncompressed, (err) => {
                    fs.unlink(files[file_key][0].path, () => {} );
                  
                    const stats = fs.statSync(files[file_key][0].path+"_uncompressed");
                    var fileSizeElement = {
                        type: "element",
                        name: "originalFileSize",
                        elements: [{
                            type: "text",
                            text: stats.size
                        }]
                    }

                    var filePathElement = {
                        type: "element",
                        name: "tempFilePath",
                        elements: [{
                            type: "text",
                            text: files[file_key][0].path + "_uncompressed"
                        }]
                    }

                    var fileNameElement = {
                        type: "element",
                        name: "originalFileName",
                        elements: [{
                            type: "text",
                            text: files[file_key][0].originalFilename
                        }]
                    }

                    res_xml.elements[0].elements[1].elements[0].elements.push(fileNameElement);
                    res_xml.elements[0].elements[1].elements[0].elements.push(filePathElement);
                    res_xml.elements[0].elements[1].elements[0].elements.push(fileSizeElement);

                    response = convert.js2xml(res_xml);
                    req.body = response;
                    next()
                })
            })
        })
    } else {
        next()
    }
}

...maybe this helps

@allanmayanei1
Copy link

Infelizmente não temos largura de banda para implementar o suporte MTOM, mas contribuições são bem vindas!

I made this contribution on the fork: add attachments how to pull requests

@allanmayanei1 allanmayanei1 mentioned this issue Jul 16, 2019
2 tasks
@stale
Copy link

stale bot commented Oct 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 24, 2019
@stale
Copy link

stale bot commented Nov 7, 2019

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants