title: How to calculate wsse nonce?
body: <p>I am getting an error while trying to send a soap request (soapCall) to the server.</p>
  
  <pre><code>Fatal error: Uncaught SoapFault exception: [ns1:InvalidSecurity] An error was discovered processing the &lt;wsse:Security&gt; header
  </code></pre>
  
  <p>I need to send the ws-security header</p>
  
  <pre><code>&lt;wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
  
  &lt;wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
  
  &lt;wsse:Username&gt;userID&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;passwd&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;ZTQ3YmJjZmM1ZTU5ODg3YQ==&lt;/wsse:Nonce&gt;
  
  &lt;wsu:Created&gt;2013-07-05T19:55:36.458Z&lt;/wsu:Created&gt;
  
  &lt;/wsse:UsernameToken&gt;
  &lt;/wsse:Security&gt;
  </code></pre>
  
  <p>After a lot of research I think the issue I got is the nonce didnt meet the requirement. As I am making up the soap header looks like the example I got. The only unknown element is to calculating this nonce...</p>
  
  <p>From the example nonce I got, its a set of 24 numbers + alphabet + special character </p>
  
  <p>Something like this</p>
  
  <pre><code>ZTQ3YmJjZmM1ZTU5ODg3YQ==
  </code></pre>
  
  <p>But however, I am not too sure how do you calculate the wsse nonce from php...is there any standard?</p>
  
  <p>the code I had</p>
  
  <pre><code>$nonce = sha1(mt_rand());
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>dabddf9dbd95b490ace429f7ad6b55c3418cdd58
  </code></pre>
  
  <p>which is something completely different than the example...and I believe this is the reason why this code is not working.</p>
  
  <p>So I am doing more research and now I am using this     </p>
  
  <pre><code>$NASC = substr(md5(uniqid('the_password_i_am _using', true)), 0, 16);
  $nonce = base64_encode($NASC); 
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>NzJlMDQ4OTAyZWIxYWU5ZA==
  </code></pre>
  
  <p>Now, it looks similar to the example but I still getting that error showed from the beginning.</p>
  
  <p>Can someone give me a hand please?</p>
  
  <p>some further testing with soapUI.</p>
  
  <p>same userID and passwd, set the passwordtype to passwordtext</p>
  
  <p>and it is working.</p>
  
  <p>is anyone know how do the soapUI calculate the nonce? or have any idea how soapUI passing the ws-security?</p>