Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('soap.wsdl_cache_enabled',0);
- ini_set('soap.wsdl_cache_ttl',0);
- ini_set('default_socket_timeout', 15);
- ini_set('default_socket_timeout', 1000);
- 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);
- }
- }
- # credencials
- $username = "XXXXX";
- $password = "XXXXXXXXX";
- $checkVatParameters = array('fromDate' =>'XXXX' ,
- 'toDate' =>'XXXXX',
- );
- $Values = new stdClass();
- $Values->User = new SoapVar($username, XSD_STRING, NULL, "", NULL, "");
- $Header = new SOAPHeader("urn:/microsoft/multichannelframework/", 'Values', $Values, true);
- $options = array(
- 'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
- 'style'=>SOAP_RPC,
- 'use'=>SOAP_ENCODED,
- 'soap_version'=>SOAP_1_1,
- 'cache_wsdl'=>WSDL_CACHE_NONE,
- 'connection_timeout'=>300,
- 'trace'=>1,
- 'encoding'=>'UTF-8',
- 'exceptions'=>true,
- );
- # request
- try {
- #print "1";
- $wsse_header = new WsseAuthHeader($username, $password);
- $soap = new SoapClient('XXXXXXXXX.wsdl', $options);
- $soap->__setSoapHeaders(array($Header,$wsse_header));
- $data = $soap->searchBatches($checkVatParameters);
- }
- catch(Exception $e) {
- // print "2";
- echo $soap->__getLastRequest();
- #print "<pre>" . print_r($soap,1) . "</pre>";
- die($e->getMessage());
- }
- print "3";
- var_dump($data);
- die;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement