Node.js - Problems using the SOAP library
I am trying to use this package: https://github.com/milewise/node-soap
Howeve开发者_StackOverflowr, when I do this:
var soap = require('soap');
var url = 'http://example.com/wsdl?wsdl';
var args = {name: 'value'};
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.log(result);
});
});
It returns back: "undefined".
My question is I don't understand when it says "args". Is it to do with the nodes in the WDSL?
The WSDL file is as follows:
<xsd:element name="getAllMarkets">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="request" type="types:GetAllMarketsReq"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Please help. Thanks.
You are logging result
, which is probably undefined because there's an error, meaning the err
argument to your callback function IS defined and will have info for you. In this case since it looks like you're calling MyFunction
instead of getAllMarkets
, your error will probably be some sort of "Unknown Method" error. Do console.log(err, result);
and see what that prints out.
instead of this :
var args = {name: 'value'};
try this :
var args = {'tns:name': 'value'};
its worked for me.
try
var args = { request: { name: 'value' } };
精彩评论