title: Create a WS-Security header using SimpleXML?
body: <p>I want to create a WSS header to authentificate on secured web services.</p>
  
  <p>I can do it using an ugly :</p>
  
  <pre><code>    $auth = '
       &lt;wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
          &lt;wsu:Timestamp wsu:Id="Timestamp-28" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
              &lt;wsu:Created&gt;' . $timestamp . '&lt;/wsu:Created&gt;
              &lt;wsu:Expires&gt;' . $timestampExpires . '&lt;/wsu:Expires&gt;
          &lt;/wsu:Timestamp&gt;
          &lt;wsse:UsernameToken wsu:Id="UsernameToken-27" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
              &lt;wsse:Username&gt;' . $user . '&lt;/wsse:Username&gt;
              &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"&gt;' . $passdigest . '&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;' . $encodedNonce . '&lt;/wsse:Nonce&gt;
              &lt;wsu:Created&gt;' . $timestamp . '&lt;/wsu:Created&gt;
          &lt;/wsse:UsernameToken&gt;
       &lt;/wsse:Security&gt;';
  </code></pre>
  
  <p>I am now trying to do it cleaner, using SimpleXML.</p>
  
  <p>But if I try to do a simple :</p>
  
  <pre><code>    $xml = new SimpleXMLElement('&lt;wsse:Security/&gt;', 0, false, 'wsse');
  </code></pre>
  
  <p>I get : </p>
  
  <blockquote>
    <p>warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:
    namespace error : Namespace prefix wsse on Security is not defined in</p>
  </blockquote>
  
  <p>I think I miss something with the way to create namespaced xmls, can you give me some hints?</p>