Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending arguments via Soap in Node.js using node-soap

I am just getting started with NodeJS and I digging into talking to a SOAP service using milewise's node-soap. I am using a basic email address validation SOAP API as my test case.

I don't seem to understand the correct way to format my arguments lists.

My SOAP client code:

    var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl";
soap.createClient(url, function(err, client){
    console.log(client.describe().EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate);
    client.Validate({result:"[email protected]"}, function(err, result){
            console.log(result);
    });
});

The client.describe() command tells me how the API would like its input formatted, and how it will return its output. This is what is says:

{ input: { 'request[]': 'xs:string' }, output: { 'ValidateResult[]': 'xs:boolean' } }

However when I send the arguments as an object: {request:"[email protected]"}

I feel like my problems lies in how I am defining the arguments object...what do the brackets in request[] mean?

like image 946
Caleb Larsen Avatar asked Apr 15 '13 02:04

Caleb Larsen


1 Answers

It should work, if you add namespace on request argument. This is a sample code.

var soap = require('soap');

var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl";

var args = {"tns:request":"[email protected]"};

soap.createClient(url, function(err, client){
    client.EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate(args, function(err, result){
            if (err) throw err;
            console.log(result);
    });
});

However, it returns "Access is denied".

I use soapUI to test this web service, it returns the same result.

I try another web service, and it works.

var soap = require('soap');

var url = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl";

var args = {"tns:request":"GOOG"};

soap.createClient(url, function(err, client){

    client.StockQuoteService.BasicHttpBinding_IStockQuoteService.GetStockQuote(args, function(err, result){
            if (err) throw err;
            console.log(result);
    });
});
like image 168
Andy Cheng Avatar answered Sep 21 '22 20:09

Andy Cheng