I'm trying to write a client for russian post to get track. It uses SOAP WSDL. I'm to get at least client object.
'use strict'
let soap=require('soap'),
url = 'https://tracking.russianpost.ru/rtm34?wsdl',
argums={}
soap.createClient(url,argums,function(err, client){
console.log(client)
})
but it returns error
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
Can anyone explain what does it meand what should request look like?
Solved. Workaround of issue. First instead of their .wsdl file I use modified original wsdl file and store it locally.
workaround of xml file Fixed it by adding into schema targetnNamespace parameter.
<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>
Original wsdl code part
<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>
now to use our wsdl file:
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);
}
);
}
I solved by defined only one schema tag, example:
From:
<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>
To:
<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:import namespace="http://www.russianpost.org/RTM/DataExchangeESPP/Data"
schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=2"/>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=3"/>
<xsd:import namespace="http://russianpost.org/sms-info/data"
schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=4"/>
<xsd:import namespace="http://russianpost.org/operationhistory/data"
schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=5"/>
<xsd:import namespace="http://russianpost.org/operationhistory"
schemaLocation="https://tracking.russianpost.ru/rtm34?xsd=6"/>
</xsd:schema>
</types>
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With