sajeet
sajeet

Reputation: 133

calling soap services using nodejs having WSDl url

I am trying to call soa services using node-soap i.e: https://www.npmjs.com/package/soap

The code is:

var soap = require('soap');
  var url = 'http://localhost:8080/tc/services/Core-2008-06-DataManagement?wsdl';
  var args = {name: 'value'};
  soap.createClient(url, function(err, client) {
      client.MyFunction(args, function(err, result) {
          console.log(result);
      });
  });

But getting error while executing.."Cannot read property 'MyFunction' of undefined"

How to solve the error

Upvotes: 1

Views: 1939

Answers (3)

Sonu Kumar
Sonu Kumar

Reputation: 969

Example SOAP My case soap web service

var soap = require('soap');    
function xyzFunction() {
        var wsdl = 'http://xxy.com/Details.asmx?WSDL';
        callSoapService(wsdl, 'GetXYZMethodDataInJSON', {});
    }

    function callSoapService(wsdl, methodName, args, callback) {
        soap.createClient(wsdl, function(err, client) {
            console.log(err);
            client[methodName](args, function(err, result) {
                console.log(err);
                console.log(result);
                callback(result);
            });
        });
    }

Upvotes: 0

sajeet
sajeet

Reputation: 133

How do I run the above client behind a proxy... I tried running the code using a proxy:parameter but seems to have no effect...getting the same error that the create is not defined.

var soap = require('soap'),
    url = 'http://01hw748540:8080/tc/services/Core-2008-06-DataManagement?wsdl',
    args = { n1: '2',n2:'3' }


soap.createClient(url, function(err, client) {
    client.create(args, function(err, result) {
        console.log(result);
    }, {proxy: process.env.http_proxy});
});

Upvotes: 1

Daphoque
Daphoque

Reputation: 4678

MyFunction is just an example of the node package.

You have to call a function specified in your wsdl, here :http://localhost:8080/tc/services/Core-2008-06-DataManagement?wsdl

Example, if you have functions UpdateOrder or DeleteOrder specified in your wsdl you can call :

client.UpdateOrder(....

Upvotes: 0

Related Questions