node.js – SOAP节点返回错误Target-Namespace“undefined”已被另一个Schema使用

我正在尝试为俄罗斯帖子写一个客户端来跟踪.它使用SOAP WSDL.
我至少得到客户端对象.
'use strict'
let soap=require('soap'),url = 'https://tracking.russianpost.ru/rtm34?wsdl',argums={}

soap.createClient(url,argums,function(err,client){
    console.log(client) 
})

但它返回错误

Target-Namespace "undefined" already in use by another Schema!
Target-Namespace "undefined" already in use by another Schema!
Target-Namespace "undefined" already in use by another Schema!
Target-Namespace "undefined" already in use by another Schema!
Target-Namespace "undefined" already in use by another Schema!
/home/st.cremer/Сайты/get-posts/node_modules/soap/lib/wsdl.js:481
    this.element = schema.elements[nsName.name];
                         ^

TypeError: Cannot read property 'elements' of undefined

任何人都可以解释它是什么以及应该要求的样子?

解决方法

解决了.问题的解决方法.
首先,我使用修改后的原始wsdl文件而不是他们的.wsdl文件,并将其存储在本地.

xml文件的变通方法通过添加到模式targetnNamespace参数来修复它.

<deFinitions ... xmlns:myns="http://russianpost.org/operationhistory">
<types>
    <xsd:schema targetNamespace="http://www.russianpost.org/custom-duty-info/data">
        <xsd:import namespace="http://www.russianpost.org/custom-duty-info/data"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=1"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://www.russianpost.org/RTM/DataExchangeESPP/Data">
        <xsd:import namespace="http://www.russianpost.org/RTM/DataExchangeESPP/Data"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=2"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/">
        <xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=3"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://russianpost.org/sms-info/data">
        <xsd:import namespace="http://russianpost.org/sms-info/data"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=4"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://russianpost.org/operationhistory/data">
        <xsd:import namespace="http://russianpost.org/operationhistory/data"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=5"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://russianpost.org/operationhistory">
        <xsd:import namespace="http://russianpost.org/operationhistory"
                    schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=6"/>
    </xsd:schema>
</types>
<message name="getoperationHistory" targetNamespace="http://russianpost.org/operationhistory">
    <part name="parameters" element="tns:getoperationHistory"/>
</message>

原始的wsdl代码部分

<types>
    <xsd:schema>
        <xsd:import namespace="http://www.russianpost.org/custom-duty-info/data" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=1"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://www.russianpost.org/RTM/DataExchangeESPP/Data" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=2"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=3"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://russianpost.org/sms-info/data" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=4"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://russianpost.org/operationhistory/data" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=5"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://russianpost.org/operationhistory" schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=6"/>
    </xsd:schema>
</types>
<message name="getoperationHistory">
    <part name="parameters" element="tns:getoperationHistory"/>
</message>

现在使用我们的wsdl文件

var SoapClient = require('soap');
var options = {
    'trace': 1,"overrideRootElement": {
        "namespace": "myns","xmlnsAttributes": [{
            "name": "xmlns:ns2","value": "http://russianpost.org/operationhistory"
        }]
    },forceSoap12Headers: true,connection: 'keep-alive','soap_version': 2
};
SoapClient.createClient('./local_wsdl.xml',options,function (err,client) {
    client.getoperationHistory(
        {
        'ns1:OperationHistoryRequest': {
            'ns1:Barcode': trackValue,'ns1:MessageType': 0,'ns1:Language': 'RUS',},'ns1:AuthorizationHeader': {
            'ns1:login': login,'ns1:password': password,(err,result) => {
        if (err) {
            console.log(err);

            return;
        }

        console.log(result.OperationHistoryData);
    }
    );
}

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...