A simple soap call does not work (Nodejs, easysoap)

I am having some problems with easysoap ( https://npmjs.org/package/easysoap ) and I could not find a lot of documentation or people talking about it, so I hope some of you can help:

I 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 stating that I am not authorized to fulfill my request. However, if I manually try to use the same URL in the http://somewhere.com:9001/somews.asmx browser, it works.

Do you know what I'm doing wrong?

Thank you very much in advance.

If any of you are aware of any other node module, in order to achieve this, please let me know. I tried to use node-soap, but got lost in all the necessary dependencies: python, Visual Studio ... do you really need all this to make a couple of soapy calls to the server ???

thanks

+5
source share
2 answers

For other nodejs soap modules. I am currently using node-soap and am happy with this. Here you can find the project here .

Here is an example of how I use 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); }); }); 
+5
source

For me it worked:

  "use strict"; var easysoap = require('easysoap'); var clientParams = { host : 'http://somewhere.com:9001', path : '/somews.asmx', wsdl : '/somews.asmx?WSDL' }; var clientOptions = { secure : false }; var soapClient = easysoap.createClient(clientParams, clientOptions); soapClient.call({'method' : 'Execute', 'params' : { 'ExecuteXML' : 1 }}) .then(function (callResponse) { console.log(callResponse); }) .catch(function (err) { console.log("Got an error making SOAP call: ", err); }); 
0
source

Source: https://habr.com/ru/post/1489789/


All Articles