Sending arguments via Soap in Node.js using node-soap
Solution 1
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);
});
});
Solution 2
ValidateResult
takes an array request. That is what request[]
means. If it was an object it should just be request. Therefore, if you try args as follows, it may work:
var args = {request[]: ["[email protected]", "another email adress if you
want"]};
Caleb Larsen
Updated on July 23, 2022Comments
-
Caleb Larsen almost 2 years
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?