Ron
Ron

Reputation: 21

Node.js - Problems using the SOAP library

I am trying to use this package: https://github.com/milewise/node-soap

However, 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.

Upvotes: 2

Views: 4967

Answers (3)

Gil
Gil

Reputation: 1

try

var args = { request: { name: 'value' } };

Upvotes: 0

kiran Sp
kiran Sp

Reputation: 153

instead of this :

var args = {name: 'value'};

try this :

var args = {'tns:name': 'value'};

its worked for me.

Upvotes: 3

Peter Lyons
Peter Lyons

Reputation: 145984

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.

Upvotes: 3

Related Questions