11

I am trying to access a web api using node-soap module, but every time i run the code i get following error "Unexpected root element of WSDL or include"

var soap = require('soap');
var xml2js = require('xml2js');

var url = 'https://webservice.servcei.com/LoginXML';
var params = {
    Username:'webservice',
    Password:'Test123'
};
soap.createClient(url,params,function(err,client){
    console.log(err);
});
Taral Patoliya
  • 257
  • 4
  • 13
  • [related question](http://stackoverflow.com/questions/30139878/how-to-consume-wcf-in-node-js) – stuartd May 10 '16 at 10:14
  • I checked that question but could not comprehend anything, also i am not aware if the given response is returned from the web service or from soap module? – Taral Patoliya May 10 '16 at 10:18
  • Use a network capture tool [like Fiddler or Wireshark](http://stackoverflow.com/questions/4263116/wireshark-vs-firebug-vs-fiddler-pros-and-cons) to a) see exactly what you are sending and b) see exactly what you are receiving. – stuartd May 10 '16 at 10:20

1 Answers1

13

The "url" variable should point to WSDL, not the web service itself. By convention WSDL should be located on following URL: https://webservice.servcei.com/LoginXML?wsdl

So do following:

  1. Check if you can access the WSDL on following URL: https://webservice.servcei.com/LoginXML?wsdl. If not, find the correct location of WSDL file
  2. Check the service host is specified in WSDL xml. If not use "endpoint" parameter of createClient to point to real SOAP service.
Emil Alkalay
  • 476
  • 4
  • 16