php - How to calculate wsse nonce? -


i getting error while trying send soap request (soapcall) server.

fatal error: uncaught soapfault exception: [ns1:invalidsecurity] error discovered processing <wsse:security> header 

i need send ws-security header

<wsse:security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">  <wsse:usernametoken wsu:id="usernametoken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  <wsse:username>userid</wsse:username>  <wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext">passwd</wsse:password>  <wsse:nonce encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#base64binary">ztq3ymjjzmm1ztu5odg3yq==</wsse:nonce>  <wsu:created>2013-07-05t19:55:36.458z</wsu:created>  </wsse:usernametoken> </wsse:security> 

after lot of research think issue got nonce didnt meet requirement. making soap header looks example got. unknown element calculating nonce...

from example nonce got, set of 24 numbers + alphabet + special character

something this

ztq3ymjjzmm1ztu5odg3yq== 

but however, not sure how calculate wsse nonce php...is there standard?

the code had

$nonce = sha1(mt_rand()); 

result

dabddf9dbd95b490ace429f7ad6b55c3418cdd58 

which different example...and believe reason why code not working.

so doing more research , using

$nasc = substr(md5(uniqid('the_password_i_am _using', true)), 0, 16); $nonce = base64_encode($nasc);  

result

nzjlmdq4otayzwixywu5za== 

now, looks similar example still getting error showed beginning.

can give me hand please?

some further testing soapui.

same userid , passwd, set passwordtype passwordtext

and working.

is know how soapui calculate nonce? or have idea how soapui passing ws-security?

try

        string usn = "myusername";         string pwd = "mypassword";          datetime created = datetime.now.touniversaltime();         var nonce = getnonce();         string noncetosend = convert.tobase64string(encoding.utf8.getbytes(nonce));         string createdstr = created.tostring("yyyy-mm-ddthh:mm:ssz");         string passwordtosend = getsha1string(nonce + createdstr + pwd); 

and functions:

protected string getnonce()     {         string phrase = guid.newguid().tostring();         return phrase;      }      protected string getsha1string(string phrase)     {         sha1cryptoserviceprovider sha1hasher = new sha1cryptoserviceprovider();         byte[] hasheddatabytes = sha1hasher.computehash(encoding.utf8.getbytes(phrase));         string test = convert.tostring(hasheddatabytes);         return convert.tobase64string(hasheddatabytes);     } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -