title: How to: PHP SoapClient example incorporating WSSE Header
body: <p>I have a WSDL file. Using SOAP UI, I was able to generate the SOAP request message...</p>
  
  <p><strong>Request SOAP message:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  
  &lt;SOAP-ENV:Header&gt;
      &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1"&gt;
      &lt;wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="ABCGID-123456789"&gt;
          &lt;wsse:Username&gt;Spiderman&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;spinningtheweb&lt;/wsse:Password&gt;
  &lt;/wsse:UsernameToken&gt;
      &lt;/wsse:Security&gt;
  &lt;/SOAP-ENV:Header&gt;
  
  &lt;SOAP-ENV:Body&gt;
      &lt;FooInterface_Bar_Input xmlns="http://example.com/interfaces"&gt;
          &lt;Input1&gt;Howdy&lt;/Input1&gt;
          &lt;Input2&gt;Partner&lt;/Input2&gt;
      &lt;/FooInterface_Bar_Input&gt;
  &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p><strong>And here is the response SOAP message:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  
  &lt;SOAP-ENV:Body&gt;
      &lt;ns:FooInterface_Bar_Output xmlns:ns="http://example.com/interfaces"&gt;
      &lt;ns:Output1&gt;Banana&lt;/ns:Output1&gt;
      &lt;ns:Output2&gt;Papaya&lt;/ns:Output2&gt;
      &lt;listOfOtherOutputs&gt;
         &lt;Output3&gt;Apple&lt;/Output3&gt;
      &lt;/listOfOtherOutputs&gt;
  &lt;/ns:FooInterface_Bar_Output&gt;
  &lt;/SOAP-ENV:Body&gt;
  
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p><strong>QUESTION:</strong></p>
  
  <p>Using PHP's SoapClient, how do I:</p>
  
  <ol>
  <li>init SoapClient and load the WSDL file (which sits in my server)?</li>
  <li>Set the header?</li>
  <li>Send the SOAP request?</li>
  <li>And finally, get a SOAP response back and extract the values of <strong>Output1, Output2, and Output3</strong> into variables?</li>
  </ol>
  
  <p>I've browse previous StackOverflow questions regarding SOAP and WSSE headers, but could not find the answer.</p>
  
  <p>Thanks very much in advance for your time and your expert help!</p>
  
  <p>PS: I can accomplish the above using cURL. But I want to know how to do it using SoapClient. Thanks again!</p>