title: Simple webservice with node-soap
body: <p>I am trying to implement a simple web service using SOAP using Node Js and node-soap, but the client side seems to have problems using the server.</p>
  
  <pre><code>assert.js:92
    throw new assert.AssertionError({
          ^
  AssertionError: invalid message definition for document style binding
  </code></pre>
  
  <p>My wsdl file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wsdl:definitions name="wscalc1"
                    targetNamespace="http://localhost:8000/wscalc1"
                    xmlns="http://localhost:8000/wscalc1"
                    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"&gt;
  
    &lt;wsdl:message name="sumarRequest"&gt;
      &lt;wsdl:part name="a" type="xs:string"&gt;&lt;/wsdl:part&gt;
      &lt;wsdl:part name="b" type="xs:string"&gt;&lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
  
    &lt;wsdl:message name="multiplicarRequest"&gt;
      &lt;wsdl:part name="a" type="xs:string"&gt;&lt;/wsdl:part&gt;
      &lt;wsdl:part name="b" type="xs:string"&gt;&lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
  
    &lt;wsdl:message name="multiplicarResponse"&gt;
      &lt;wsdl:part name="res" type="xs:string"&gt;&lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
  
    &lt;wsdl:message name="sumarResponse"&gt;
      &lt;wsdl:part name="res" type="xs:string"&gt;&lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
  
  
    &lt;wsdl:portType name="calcP"&gt;
      &lt;wsdl:operation name="sumar"&gt;
        &lt;wsdl:input message="sumarRequest"&gt;&lt;/wsdl:input&gt;
        &lt;wsdl:output message="sumarResponse"&gt;&lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  
      &lt;wsdl:operation name="multiplicar"&gt;
        &lt;wsdl:input message="multiplicarRequest"&gt;&lt;/wsdl:input&gt;
        &lt;wsdl:output message="multiplicarResponse"&gt;&lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
    &lt;/wsdl:portType&gt;
  
    &lt;wsdl:binding name="calcB" type="calcP"&gt;
      &lt;soap:binding style="document" 
                    transport="http://schemas.xmlsoap.org/soap/http"/&gt;
  
      &lt;wsdl:operation name="sumar"&gt;
        &lt;soap:operation soapAction="sumar"/&gt;
        &lt;wsdl:input&gt;
          &lt;soap:body use="literal" 
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
        &lt;/wsdl:input&gt;
        &lt;wsdl:output&gt;
          &lt;soap:body use="literal" 
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
        &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  
      &lt;wsdl:operation name="multiplicar"&gt;
        &lt;soap:operation soapAction="multiplicar"/&gt;
        &lt;wsdl:input&gt;
          &lt;soap:body use="literal" 
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
        &lt;/wsdl:input&gt;
        &lt;wsdl:output&gt;
          &lt;soap:body use="literal" 
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
        &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
    &lt;/wsdl:binding&gt;
  
    &lt;wsdl:service name="ws"&gt;
      &lt;wsdl:port name="calc" binding="calcB"&gt;
        &lt;soap:address location="http://localhost:8000/wscalc1"/&gt;
      &lt;/wsdl:port&gt;
    &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>server.js</p>
  
  <pre><code>var soap = require('soap');
  var http = require('http');
  
  var service = {
      ws: {
          calc: {
              sumar : function(args) {
                  var n = args.a + args.b;
                  return { res : n };
              },
  
              multiplicar : function(args) {
                  var n = args.a * args.b;
                  return { res : n }
              }
          }
      }
  }
  
  var xml = require('fs').readFileSync('wscalc1.wsdl', 'utf8'),
  
  server = http.createServer(function(request,response) {
      response.end("404: Not Found: "+request.url)
  });
  
  server.listen(8000);
  soap.listen(server, '/wscalc1', service, xml);
  </code></pre>
  
  <p>client.js</p>
  
  <pre><code>var soap = require('soap');
  var url = 'http://localhost:8000/wscalc1?wsdl';
  soap.createClient(url, function(err, client) {
  
      if (err) throw err;
  
  
      console.log(client.describe().ws.calc);
  
      client.multiplicar({"a":"1","b":"2"},function(err,res){
          if (err) throw err;
  
          console.log(res);
      });
  });
  </code></pre>
  
  <p>with that code the output is:</p>
  
  <pre><code>{ sumar: 
     { input: { a1: 'Request', b1: 'Request' },
       output: { res: 'Response' } },
    multiplicar: 
     { input: { a2: 'Request', b2: 'Request' },
       output: { res: 'Response' } } }
  
  assert.js:92
    throw new assert.AssertionError({
          ^
  AssertionError: invalid message definition for document style binding
  </code></pre>
  
  <p>any help will be really appreciated </p>