title: Node JS: SOAP to query Java Web Services
body: <p>I am trying to invoke Javaweb services from node js module. However, I get error in the wsdl library. Here is my wsdl file.</p>
  
  <pre><code>&lt;!--
   Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. 
  --&gt;&lt;!--
   Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. 
  --&gt;&lt;definitions targetNamespace="http://jaxws.joshis1.com/" name="webServiceImplService"&gt;&lt;types&gt;&lt;xsd:schema&gt;&lt;xsd:import namespace="http://jaxws.joshis1.com/" schemaLocation="http://localhost:8888/webservice/helloworld?xsd=1"/&gt;&lt;/xsd:schema&gt;&lt;/types&gt;&lt;message name="sayHello"&gt;&lt;part name="parameters" element="tns:sayHello"/&gt;&lt;/message&gt;&lt;message name="sayHelloResponse"&gt;&lt;part name="parameters" element="tns:sayHelloResponse"/&gt;&lt;/message&gt;&lt;portType name="IwebServiceInterface"&gt;&lt;operation name="sayHello"&gt;&lt;input wsam:Action="http://jaxws.joshis1.com/IwebServiceInterface/sayHelloRequest" message="tns:sayHello"/&gt;&lt;output wsam:Action="http://jaxws.joshis1.com/IwebServiceInterface/sayHelloResponse" message="tns:sayHelloResponse"/&gt;&lt;/operation&gt;&lt;/portType&gt;&lt;binding name="webServiceImplPortBinding" type="tns:IwebServiceInterface"&gt;&lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;&lt;operation name="sayHello"&gt;&lt;soap:operation soapAction=""/&gt;&lt;input&gt;&lt;soap:body use="literal"/&gt;&lt;/input&gt;&lt;output&gt;&lt;soap:body use="literal"/&gt;&lt;/output&gt;&lt;/operation&gt;&lt;/binding&gt;&lt;service name="webServiceImplService"&gt;&lt;port name="webServiceImplPort" binding="tns:webServiceImplPortBinding"&gt;&lt;soap:address location="http://localhost:8888/webservice/helloworld"/&gt;&lt;/port&gt;&lt;/service&gt;&lt;/definitions&gt;
  </code></pre>
  
  <p>Here is my test.js</p>
  
  <pre><code>  var soap = require('soap');
    var url = 'http://localhost:8888/webservice/helloworld?wsd';
    var args = {sayHello: 'ABC'};
    soap.createClient(url, function(err, client) {
        client.MyFunction(args, function(err, result) {
            console.log(result);
        });
    }); 
  </code></pre>
  
  <p>On running, I get the following error - </p>
  
  <pre><code>node_modules/soap/lib/wsdl.js:68
    const [topLevelName] = nsName.split('|');
          ^
  
  SyntaxError: Unexpected token [
      at exports.runInThisContext (vm.js:53:16)
      at Module._compile (module.js:374:25)
      at Object.Module._extensions..js (module.js:417:10)
      at Module.load (module.js:344:32)
      at Function.Module._load (module.js:301:12)
      at Module.require (module.js:354:17)
      at require (internal/module.js:12:17)
  </code></pre>
  
  <p>$node --version
  v4.2.6</p>
  
  <p>Is there any other way like jquery to call this java web service?</p>
  
  <pre><code>node test.js 
  /home/sjoshi/test.js:5
        client.sayHello(args, function(err, result) {
               ^
  
  TypeError: Cannot read property 'sayHello' of undefined
  </code></pre>