gpt4 book ai didi

node-soap - 如何在 node-soap 中设置前缀?

转载 作者:行者123 更新时间:2023-12-01 00:02:16 25 4
gpt4 key购买 nike

具体有没有人知道我如何从 <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>

谢谢!

最佳答案

尝试一下

let options = {envelopeKey: 'soapenv'};

soap.createClient(url,options, function(err, client) {
...
}

关于node-soap - 如何在 node-soap 中设置前缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42591301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com