-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support for soap attachments in response. #1148
Conversation
@DPM1 Thanks, Absolutely agreed on include attachments into the result woult be great and the preferred solution. UPDATE :) |
feat: add mtomAttachments to result
Hi There! Is it becaues of travis-ci.org is deprecated and moved to travis-ci.com? |
Would be great to get this into the next release. If anyone would be nice enough to do a review, I would be happy to then do any work required to get this released. |
please resolve the conflicts |
remove accidentally re-added request package
package.json
Outdated
"tslint": "^5.18.0", | ||
"typedoc": "^0.20.36", | ||
"typescript": "^3.3.3333" | ||
"name": "soap", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert the white space changes in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
You compared with a previous commit, it is already fixed in the latest commit in master.
https://github.com/vpulim/node-soap/pull/1148/files
if(responseXML) requestContext.responseToSend = responseXML; | ||
if (responseXML) { | ||
if (wsdlOptions.parseReponseAttachments) {//all LF to CRLF | ||
responseXML = responseXML.replace(/\r\n/g, "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're converting rn, to n, then you're converting n back to rn. please revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
It is needed, might be implemented in different way, but needed.
The reason for that is only CRLF allowed in the multipart/related response. And in linux systems (for example travis-ci) git repo pulled with LF only so the responseXML had LF lineendings. However if response xml has LF line endings the standart http multipart response parser cannot parse it so tests fails.
What that two lines of code does is to replace all "\n" to "\r\n" .
If line 156 would have been left out responseXML = responseXML.replace(/\r\n/g, "\n");
and only line 157 would be executed than it might occur that some line endings will have "\r\r\n" and that is not correct of course.
So someone with better regexp knowledge might add a solution to replace all LF to CRLF without replacing the LF parts of CRLF's but it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you're saying there may be a mix of rn initially, so your strategy is to convert those to n then convert all n to rn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
These lines are because of I noticed that tests fails on linux system, and the reason was that there were \n -s in the file.
So I replaced all to \n to \r\n in a dirty way I mean taking care of not to replace \r\n to \r\r\n...
@jsdevel Is there a target to get this into a release? I desperately need this! |
Summary
With this modification the lib can parse the multipart/related http response, and get the (binary) attachments from it.
Configuration
The funcionality is behind a boolean option called parseReponseAttachments (default: false, not to affect previous functionality)
If mtomResponse is set to true we expect a multipart response however it can handle normal soap response (without attachment) as well.
Modification list
Dependencies
Example usage
const client = soap.createClientAsync(wsdl, { parseReponseAttachments: true} );
await client.methodAsync(json)
const attachments = client.lastResponseAttachments
Docs
W3C not about soap attachments: https://www.w3.org/TR/SOAP-attachments/
Other
The modification is similar to #1119 but configurable and working.