我正在使用这个npm-module:https://github.com/vpulim/node-soap
我想要使用的Web服务仅使用SOAP 1.2,并在使用任何其他SOAP版本时返回服务器错误。
是否有人遇到过同样的问题,并且知道如何设置SOAP版本?
答案 0 :(得分:6)
使用最新版本的https://github.com/vpulim/node-soap,可以选择设置SOAP 1.2标头
var options = {
forceSoap12Headers: true
};
soap.createClient(url,options, function (err, client) {
//Your soap call here
});
IMO,我认为我们不应该修改lib,不适合升级
答案 1 :(得分:1)
你可以进入第186行的soap \ lib \ client.js并修改信封语法,使其符合soap 1.2:
//modify this with the envelope used by soap1.2:
xml = "<soap:Envelope " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
'xmlns:ns2="http://xml.apache.org/xml-soap"' +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
encoding +
this.wsdl.xmlnsInEnvelope + '>' +
//until here
((self.soapHeaders || self.security) ?
(
"<soap:Header>" +
(self.soapHeaders ? self.soapHeaders.join("\n") : "") +
(self.security ? self.security.toXML() : "") +
"</soap:Header>"
)
:
''
) +
"<soap:Body" +
(self.bodyAttributes ? self.bodyAttributes.join(' ') : '') +
">" +
message +
"</soap:Body>" +
"</soap:Envelope>";
答案 2 :(得分:1)
我已经解决了问题,因为NicolasZ说,我目前的soap / lib / client.js是:
第187行:
xml = "<soap:Envelope " +
//"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
encoding +
this.wsdl.xmlnsInEnvelope + '>' +
((self.soapHeaders || self.security) ?
(
"<soap:Header>" +
(self.soapHeaders ? self.soapHeaders.join("\n") : "") +
(self.security ? self.security.toXML() : "") +
"</soap:Header>"
)
:
''
) +
"<soap:Body" +
(self.bodyAttributes ? self.bodyAttributes.join(' ') : '') +
">" +
message +
"</soap:Body>" +
"</soap:Envelope>";