title: SOAP with Node.js & arguments spreading
body: <p>I have to consume a SOAP API which is basically designed for PHP and has always been user with a PHP client. Problem is, I work with Node.js, and I encounter an issue I cannot handle.
  Here is a part of "could-be-working" code :</p>
  
  <pre><code>&lt;?php
  try {
      $client = new SoapClient(null, array(
          'location' =&gt; "https://my-soap-server.com/_soap/server.php",
          'uri' =&gt; "https://my-soap-server.com",
          'encoding' =&gt; 'ISO-8859-1'
      ));
      $result = $client-&gt;myMethod('aaaa', 'bbbb', 'cccc');
      var_dump($result);
  }
  catch (SoapFault $fault) {
      trigger_error("SOAP Fault: (faultcode: {$fault-&gt;faultcode}, faultstring:{$fault-&gt;faultstring})", E_USER_ERROR);
  }
  </code></pre>
  
  <p>As you can see, arguments are passed to myMethod with a specific order, and not as an object.
  With node's soap client (node-soap or strong-soap), argument 2 must be the callback, which can give a code quite like this : (let's say the documentation gives me field 1 should be 'login', etc)</p>
  
  <pre><code>const soap = require('soap');
  
  soap
      .createClientAsync('http://my-soap-server.com')
      .then((client) =&gt; client.myMethod({
          login: 'aaaa',
          password: 'bbbb',
          randomVar: 'cccc',
      }, (error, result) =&gt; {
          if (error) {
              console.error(error);
              process.exit(1);
          }
          console.log(result);
          process.exit(0);
      })
      .catch((error) =&gt; {
          console.error(error);
          process.exit(1);
      });
  </code></pre>
  
  <p>Well, I do not have any error, but the API does not do what it is expected to do.
  So, I guess the issue is that the server does not expect an object with keys, but the arguments, spred in a certain order, just like in PHP. Is there a way to reproduce that with Node.js ?</p>
  
  <p>I hope I have been clear enough.</p>
  
  <p>Thank you very much for your help.</p>
  
  <p>EDIT : Maybe easier with the <a href="https://eml-srv.com/_soap/control.php?WSDL" rel="nofollow noreferrer">WSDL</a>, method I want to get working is Ajout_BDD.</p>
  
  <p>EDIT 2 : Well, after further investigation, it looks like the SOAP request from PHP and the one from Node.js were really different in format.
  So I made it simpler (and, unfortunately, dirtier) by using "request" lib from node and making a template from the working PHP request.
  FYI, you can dump PHP SOAP requests with the following code :</p>
  
  <pre><code>$client = new SoapClient("http://127.0.0.1:2018/test/test2?WSDL", array(
      'trace' =&gt; 1
  ));
  [...]
  var_dump($client-&gt;__getLastRequest());
  </code></pre>
  
  <p>You can also dump the Node SOAP request this way :</p>
  
  <pre><code>soap.createClientAsync('http://my-soap-server/hello?WSDL', (error, client) =&gt; client.myMethod({
      login: 'aaaa',
      password: 'bbbb',
      randomVar: 'cccc',
  }, (error, result) =&gt; {
      [...]
      console.log(client.lastRequest);
  }));
  </code></pre>
  
  <p>Then just use your favorite comparator to see what differs between your calls.</p>