Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [enter image description here][1]
- [enter image description here][2]
- [enter image description here][3]
- [enter image description here][4]
- [enter image description here][5]
- [enter image description here][6]
- [enter image description here][7]
- [enter image description here][8]
- [enter image description here][9]
- [enter image description here][10]
- [enter image description here][11]
- [enter image description here][12]
- [1]: https://i.stack.imgur.com/xagv1.png
- [2]: https://i.stack.imgur.com/sSFMY.png
- [3]: https://i.stack.imgur.com/cdzzi.png
- [4]: https://i.stack.imgur.com/3wXF8.png
- [5]: https://i.stack.imgur.com/RpFAh.png
- [6]: https://i.stack.imgur.com/zgQCx.png
- [7]: https://i.stack.imgur.com/gIR2J.png
- [8]: https://i.stack.imgur.com/qhdng.png
- [9]: https://i.stack.imgur.com/Zm1ke.png
- [10]: https://i.stack.imgur.com/VrrKz.png
- [11]: https://i.stack.imgur.com/zGaUF.png
- [12]: https://i.stack.imgur.com/G2DbQ.png
- PHP Example Codes:
- $wsdl = 'http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl';
- $local_cert = 'client_load.pem';
- $passphrase = 'password';
- $client = new SoapClient($wsdl, array('trace'=>true, 'exceptions'=>true, 'local_cert' => $local_cert, 'passphrase' => $passphrase));
- $request = array(
- "name" => 'welcome'
- );
- $results = $client->authHelloWS($request);
- var_dump($results);
- Result:
- Fatal error: Uncaught SoapFault exception: [wsse:InvalidSecurity] Missing wsse:Security header in request in D:wampwwwsoaptesttest_new_soap.php:98 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(98): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(98): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 98
- --------------------------------------------------------------
- class WsseAuthHeader extends SoapHeader {
- private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
- function __construct($user, $pass, $ns = null) {
- if ($ns) {
- $this->wss_ns = $ns;
- }
- $auth = new stdClass();
- $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $username_token = new stdClass();
- $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
- $security_sv = new SoapVar(
- new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
- SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
- parent::__construct($this->wss_ns, 'Security', $security_sv, true);
- }
- }
- $wsdlfile='http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl';
- $username='apache';
- $password='apachepwd';
- $wsse_header = new WsseAuthHeader($username, $password);
- $x = new SoapClient($wsdlfile, array("trace" => 1, "exception" => 0));
- $x->__setSoapHeaders(array($wsse_header));
- $request = array(
- "name" => 'welcome'
- );
- $results = $x->authHelloWS($request);
- var_dump($results);
- Result :
- Fatal error: Uncaught SoapFault exception: [ns2Xvpn:InvalidSecurityToken] An invalid security token was provided (An error happened processing a Username Token "{0}") in D:wampwwwsoaptesttest_new_soap.php:262 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(262): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(262): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 262
- -----------------------------------------------------------------------------------------------------
- class WsseAuthHeader extends SoapHeader {
- private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
- private $wsu_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
- function __construct($user, $pass) {
- $created = gmdate('Y-m-dTH:i:sZ');
- $nonce = mt_rand();
- $passdigest = base64_encode( pack('H*', sha1( pack('H*', $nonce) . pack('a*',$created). pack('a*',$pass))));
- $auth = new stdClass();
- $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Nonce = new SoapVar($passdigest, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Created = new SoapVar($created, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wsu_ns);
- $username_token = new stdClass();
- $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
- $security_sv = new SoapVar(
- new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
- SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
- parent::__construct($this->wss_ns, 'Security', $security_sv, true);
- }
- }
- $client = new SoapClient("http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl");
- $client->__setSoapHeaders(Array(new WsseAuthHeader("apache", "apachepwd")));
- $request = array(
- "name" => 'welcome'
- );
- $results = $client->authHelloWS($request);
- var_dump($results);
- Result :
- Fatal error: Uncaught SoapFault exception: [ns2Xvpn:InvalidSecurityToken] An invalid security token was provided (An error happened processing a Username Token "{0}") in D:wampwwwsoaptesttest_new_soap.php:306 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(306): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(306): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 306
Add Comment
Please, Sign In to add comment