title: How to set SOAP header on PHP to authenticate a web service?
body: <p>I need to set the SOAP header into this format:</p>
  
  <pre><code>&lt;soapenv:Header&gt;
      &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
          &lt;wsse:UsernameToken wsu:Id="UsernameToken-45"&gt;
              &lt;wsse:Username&gt;XXXXX&lt;/wsse:Username&gt;
              &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;XXXXXXX&lt;/wsse:Password&gt;
              &lt;wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&gt;OxWtCYYj1cX7HiZeMEqorw==&lt;/wsse:Nonce&gt;
              &lt;wsu:Created&gt;2013-09-18T07:25:50.227Z&lt;/wsu:Created&gt;
          &lt;/wsse:UsernameToken&gt;
      &lt;/wsse:Security&gt;
  &lt;/soapenv:Header&gt;
  </code></pre>
  
  <p>I've tried authenticating the webservice using the code below but it didn't work. </p>
  
  <pre><code>$momurl = "https://integrationdev.momentum.co.za/sales/CRMService/CRMLeadService_v1_0/";
  
  $client = new SoapClient(
      "$momurl",
      array(
          'trace' =&gt; 1,
          'login' =&gt; $username,
          'password' =&gt; $password
      )
  );
  </code></pre>
  
  <p>Any help would be appreciated. Thanks in advance.</p>