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:"my@emailaddress.com"}, 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:"my@emailaddress.com"}
I feel like my problems lies in how I am defining the arguments object...what do the brackets in request[] mean?
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":"my@emailaddress.com"};
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);
});
});
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[]: ["my@emailadress.com", "another email adress if you
want"]};