true, 'exceptions' => true), $ticket = null) { // Store the current ticket $this->ticket = $ticket; // Call the base class parent::__construct($wsdl, $options); } public function __call($function_name, $arguments=array()) { return $this->__soapCall($function_name, $arguments); } public function __soapCall($function_name, $arguments=array(), $options=array(), $input_headers=array(), $output_headers=array()) { if (isset($this->ticket)) { // Automatically add a security header $input_headers[] = new SoapHeader($this->securityExtNS, "Security", null, 1); // Set the JSESSION cookie value // change by moodle $sessionId = Alfresco_Repository::getSessionId($this->ticket); if ($sessionId != null) { $this->__setCookie("JSESSIONID", $sessionId); } } return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); } public function __doRequest($request, $location, $action, $version) { // If this request requires authentication we have to manually construct the // security headers. if (isset($this->ticket)) { $dom = new DOMDocument("1.0"); $dom->loadXML($request); $securityHeader = $dom->getElementsByTagName("Security"); if ($securityHeader->length != 1) { throw new Exception("Expected length: 1, Received: " . $securityHeader->length . ". No Security Header, or more than one element called Security!"); } $securityHeader = $securityHeader->item(0); // Construct Timestamp Header $timeStamp = $dom->createElementNS($this->wsUtilityNS, "Timestamp"); $createdDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+24, date("i"), date("s"), date("m"), date("d"), date("Y"))); $expiresDate = date("Y-m-d\TH:i:s\Z", mktime(date("H")+25, date("i"), date("s"), date("m"), date("d"), date("Y"))); $created = new DOMElement("Created", $createdDate, $this->wsUtilityNS); $expires = new DOMElement("Expires", $expiresDate, $this->wsUtilityNS); $timeStamp->appendChild($created); $timeStamp->appendChild($expires); // Construct UsernameToken Header $userNameToken = $dom->createElementNS($this->securityExtNS, "UsernameToken"); $userName = new DOMElement("Username", "username", $this->securityExtNS); $passWord = $dom->createElementNS($this->securityExtNS, "Password"); $typeAttr = new DOMAttr("Type", $this->passwordType); $passWord->appendChild($typeAttr); $passWord->appendChild($dom->createTextNode($this->ticket)); $userNameToken->appendChild($userName); $userNameToken->appendChild($passWord); // Construct Security Header $securityHeader->appendChild($timeStamp); $securityHeader->appendChild($userNameToken); // Save the XML Request $request = $dom->saveXML(); } return parent::__doRequest($request, $location, $action, $version); } } ?>