username=$username; $this->secret=$secret; parent::SoapClient($wsdl,$options); } private function getWSSecurityHeader() { // Some auto incrementing value in a database would // probably be a better choice than a microtime call. $nonce = hash_hmac('sha1',microtime(),$this->secret); $created = date("Y-m-d H:i:s"); $sha1_string = sha1($nonce . $created . $this->secret); $password = base64_encode($sha1_string); $authheader = new SoapVar(' '.$this->username.' '.$password.' '.$nonce.' '.$created.' ',XSD_ANYXML); return new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','Security',$authheader); } public function __call($function_name, $arguments) { $this->__setSoapHeaders($this->getWSSecurityHeader()); return parent::__Call($function_name, $arguments); } public function __soapCall ($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) { $this->__setSoapHeaders($this->getWSSecurityHeader()); return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); } } ?>