title: PHP Soap header
body: <p>I am trying to set Soap header for the WSDL and wonder if the following code is correct.</p>
  
  <p>I try to pass all 3 variables into Soap header.</p>
  
  <p>Any pointer would be much appreciated.</p>
  
  <p>Thanks</p>
  
  <p>PHP CODE:</p>
  
  <pre><code>try{
              $soap_client = new SoapClient('https://mywebservice.com/ws.php?wsdl');
  
              //Body of the Soap Header.       
              $soapheader = $this-&gt;getMRSoapHeader("PortalOnlineInventorySearch");
              $headerbody = array('Timestamp' =&gt; $soapheader['Timestamp'],
                                  'Signature' =&gt; $soapheader['Signature'],
                                  'AccessID'  =&gt; $soapheader['AccessID']);
  
              //Create Soap Header.       
              $header = new SOAPHeader($this-&gt;ns, 'WebServiceSoapHeader', $headerbody);       
  
              //set the Headers of Soap Client.
              $soap_client-&gt;__setSoapHeaders($header); 
  
              $searchResult = $soap_client-&gt;PortalOnlineInventorySearch($meetingRoomOnlineSearchCriteria);
          }catch (Exception  $e){
               error_log("Error getting Search Results from Titan" + $e-&gt;getMessage());            
               var_dump("Error performing criteria search" . $e-&gt;getMessage());
          }
  </code></pre>
  
  <p>WSDL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soap12:Header&gt;
      &lt;WebServiceSoapHeader xmlns="https://mywebservice.com/ws.php?wsdl"&gt;
        &lt;Signature&gt;string&lt;/Signature&gt;
        &lt;AccessID&gt;string&lt;/AccessID&gt;
        &lt;Timestamp&gt;string&lt;/Timestamp&gt;
      &lt;/WebServiceSoapHeader&gt;
    &lt;/soap12:Header&gt;
    &lt;soap12:Body&gt;
      &lt;PortalOnlineInventorySearch xmlns="https://mywebservice.com/ws.php"&gt;
        &lt;searchCriteria&gt;            
          &lt;keyword&gt;int&lt;/keyword&gt;
          &lt;ReturnServices&gt;boolean&lt;/ReturnServices&gt;            
        &lt;/searchCriteria&gt;
      &lt;/PortalOnlineInventorySearch&gt;
    &lt;/soap12:Body&gt;
  &lt;/soap12:Envelope&gt;
  </code></pre>