title: PHP NuSoap correct way of sending headers
body: <p>I've been stuck with a HTTP 400 "Bad Request" issue when trying to connect to an API for some time now.</p>
  
  <p>I have a feeling it's to do with the headers, but I'm not too sure.</p>
  
  <p>My query is regarding the output of the SOAP Request and whether I'm correctly setting the headers.</p>
  
  <p>So the code I have to set the header is</p>
  
  <pre><code>$proxy-&gt;setHeaders('&lt;soap:Header&gt;&lt;AuthenticationSoapHeader xmlns="https://www.xxxxx.com/ASPAPI"&gt;&lt;Token&gt;xxxxx-xxxxx-xxxx&lt;/Token&gt;&lt;/AuthenticationSoapHeader&gt;&lt;/soap:Header&gt;');
  </code></pre>
  
  <p>I then make a call to an API function and pass over the XML string directly after setting the headers, like so:</p>
  
  <pre><code>$result = $proxy-&gt;call('ValidateService', array('serviceXML' =&gt; $xml));
  </code></pre>
  
  <p>However, the output when printing <code>$proxy-&gt;request</code> is like so:</p>
  
  <pre><code>[TOKEN VALUE FROM HEADER HERE][CONTENTS OF XML STRING HERE]
  </code></pre>
  
  <p>So the <code>request</code> string basically prints out the contents of inside the <code>&lt;token&gt;</code> tag in the header, directly followed by the XML string.</p>
  
  <p>Is it right that the <code>&lt;token&gt;</code> value is printed out in the request alongside the XML string? I have a feeling I may be incorrectly setting the headers.</p>