Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple soap call is failing (Nodejs, easysoap)

I am having some problems with easysoap (https://npmjs.org/package/easysoap) and I have been unable to find much documentation or people talking about it, so I hope some of you can help:

I’m making a simple call like this:

            var clientParams = {
                           host    : 'somewhere.com',
                           port    : '9001',
                           path    : '/somews.asmx',
                           wsdl    : '/somews.asmx?WSDL'
            };

            var clientOptions = {
                           secure : false 
            };

            //create new soap client
            var SoapClient = new soap.Client(clientParams, clientOptions);
            SoapClient.once('initialized', function() {

                           //successful initialized
                           SoapClient.once('soapMethod', function(data, header) {
                           });

                           console.log('call');

                           SoapClient.call({
                                           'method' : 'Execute',
                                           'params' : {
                                                           'ExecuteXML' : 1
                                           }}, function(attrs, err, responseArray, header){
                                           }
                           );
            });

            //initialize soap client
            SoapClient.init();  

The problem Is that I get a response saying that I am not authorized to make my request.However if I manually try the same url in the browser http://somewhere.com:9001/somews.asmx it does work.

Do you know what am I doing wrong?

Many many thanks in advance.

If any of you know of any other node module to achieve this please let me know. I attempted to use node-soap but got lost in all the dependencies required: python, Visual Studio... you really need all that to make a couple of soap calls to a server???

Thanks

like image 201
Rafa Llorente Avatar asked Jul 04 '13 19:07

Rafa Llorente


1 Answers

For other nodejs soap modules. I currently use node-soap and am happy with it. You can find the project here.

Here is an example of how I'm using it.

var soap = require('soap');
//example url
var url = 'http://ws.strikeiron.com/GlobalAddressVerification5?WSDL';

var soapHeader = ''//xml string for header


soap.createClient(url, function(err, client){
  client.addSoapHeader(soapHeader);

  var args = {
    StreetAddressLines: "5322 Otter Lane",
    CountrySpecificLocalityLine: "Middleberge FL 32068",
    Country: "USA"
  };

  client.BasicVerify(args, function(err, result){
   if(err){
     throw err;
   }
   console.log(result);
  });
});
like image 79
BenDavidJamin Avatar answered Oct 26 '22 20:10

BenDavidJamin