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);
    }
    );
}

相关文章

现在的js代码都是这种高级点的方式语法 , 就是ts语法 ,要使用ts语法那就要先安装一下 先安装nodejs最...
nvm是node版本管理工具 为了解决node各种版本存在不兼容现象 nvm是让你在同一台机器上安装和切换不同版...
1、安装nodejs 2、在项目文件夹目录下创建一个js文件,命名server.js(自定义名称),内容如下 3、打开命令...
1.连接路径:path.join([path1][, path2][, ...]) path.join()方法可以连接任意多个路径字符串。要连接...
简介 1.aes加密简单来说,在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。这个...
定义 Object.keys 定义:返回一个对象可枚举属性的字符串数组; Object.getOwnPropertyNames 定义:返回...