-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I'm having some trouble reading an attachment from the soap response using.
var file = ws.getAttachment(ctx, "response", "//*[local-name(.)='File1']"); //fs.writeFileSync("result.pdf", file);
after much hacking around I was able to get the file from the soap response by adding
fs.writeFileSync("result.pdf", parts[1].data);
to mtom.js after this block of code
` //use slice() since in http multipart response the first chars are #13#10 which the parser does not expect
var parts = reader.parse_multipart(ctx.response.slice(2), boundary)
if (parts.length==0) {
console.log("warning: no mime parts in response")
callback(ctx)
return
}`
two things that I'm not sure of are:
- in ws.getAttachment(ctx, "response", "//[local-name(.)='File1']"); what this is doing //[local-name(.)='File1'].
- what this block of code in mtom.js is trying to do
for (var i in parts) { var p = parts[i] , id = utils.extractContentId(p.headers["content-id"] ) , xpath = "//*[@href='cid:" + encodeURIComponent(id) + "']//parent::*" , elem = select(doc, xpath)[0] console.log(elem); if (!elem) continue elem.removeChild(elem.firstChild) utils.setElementValue(doc, elem, p.data.toString("base64")) }
fyi the console.log(elem) is returning undefined for each part[0] and part[1] when I run it.
the error I'm getting when I try to run is:
c:\node\test\node_modules\ws.js\lib\ws.js:69
return new Buffer(elem.firstChild.data, "base64")
^
TypeError: Cannot read property 'firstChild' of undefined
at Object.getAttachment (c:\node\test\node_modules\ws.js\lib\ws.js:69:25)