具体是否有人知道我如何将命名空间从<soap:Header>
更改为<soapenv:Header>
,同样属性为soapenv:mustUnderstand="1"
?
我的代码目前看起来像这样:
const soap = require('soap');
const url = 'https://staging.identitymanagement.lexisnexis.com/identity-proofing/services/identityProofingServiceWS/v2?wsdl';
soap.createClient(url, function(err, client) {
if(err) {
console.log('Error', err);
}
client.setSecurity(new soap.WSSecurity('username', 'password', { 'mustUnderstand': 1}));
client.invokeIdentityService({ 'workFlow': 'SOME_FLOW' }, (err, result, raw, soapHeader) => {
console.log('Error======================');
console.log(err);
console.log('Result=============================');
console.log(result);
console.log('raw==============================');
console.log(raw);
console.log('soapHeader', soapHeader);
});
});
它生成的XML看起来像这样......
<?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" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:tns="http://ws.identityproofing.idm.risk.lexisnexis.com/" xmlns:survey="http://ns.lexisnexis.com/survey/1.0" xmlns:identity="http://ns.lexisnexis.com/identity-proofing/1.0" xmlns:ns0="http://ns.lexisnexis.com/identity-proofing/1.0">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-2017-03-04T01:58:02Z">
<wsu:Created>2017-03-04T01:58:02Z</wsu:Created>
<wsu:Expires>2017-03-04T02:08:02Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-2017-03-04T01:58:02Z">
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
<wsu:Created>2017-03-04T01:58:02Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<tns:invokeIdentityService xmlns:ns2="http://tempuri.org/" xmlns:ns3="http://sillypets.com/xsd">
<workFlow>SOME_FLOW</workFlow>
</tns:invokeIdentityService>
</soap:Body>
</soap:Envelope>
谢谢!
答案 0 :(得分:-2)
试试吧
let options = {envelopeKey: 'soapenv'};
soap.createClient(url,options, function(err, client) {
...
}