发送前,请从肥皂请求xml中删除并覆盖一些属性,

时间:2019-05-02 09:26:35

标签: node.js xml soap soap-client node-soap

在节点肥皂客户端中,我必须删除xmlns:xsi并使用xmlns:ser覆盖xmlns:tns

我尝试了很多,但无法这样做。需要帮助

const url = 'http://host:9001/xyz/abc/something?wsdl';

var wsdlOptions = {
    "overrideRootElement": {
        "namespace": "ser"
    },
    "envelopeKey": "soapenv",
    "useEmptyTag": true,
    "ignoredNamespaces": {
        "namespaces": ['tns', 'xsi'],
        "override": true
      }
};

soap.createClient(url, wsdlOptions, async function (err, client) {
    if (err) {
        console.log(err)
    } else {
        var args = {
            AccountNo: '751600412147',
            PaymentSource:'SuvidhaPayment'
        };
        client.getConsumerEnquiryDetails(args, function (err, result) {
            if (err) {
                console.log(JSON.stringify(err, null, 2));
            } else {
                console.log(result);
            }
        }); 
    }
});

我希望输出像这样

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://service.collections.phoenix.com/">
    <soapenv:Body>
        <ser:getConsumerEnquiryDetails>
            <AccountNo>Mz9hvPk+osEI4MO3fiqbIA==</AccountNo>
            <PaymentSource>MlvdhUGnYrYyui0U1HcQYw==</PaymentSource>
        </ser:getConsumerEnquiryDetails>
    </soapenv:Body>
</soapenv:Envelope>

但是我使用xmlns:xsi和xmlns:tns(而不是xmlns:ser)来获取这个

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://service.collections.phoenix.com/">
    <soapenv:Body>
        <ser:getConsumerEnquiryDetails>
            <AccountNo>Mz9hvPk+osEI4MO3fiqbIA==</AccountNo>
            <PaymentSource>MlvdhUGnYrYyui0U1HcQYw==</PaymentSource>
        </ser:getConsumerEnquiryDetails>
    </soapenv:Body>
</soapenv:Envelope>

0 个答案:

没有答案