示例#1
0
 /**
  * Get the request
  *
  * @return string
  */
 public function getRequest()
 {
     $dom = new DOMDocument('1.0', API::$encoding);
     $credentialsElement = $dom->createElement('credentials');
     $usernameElement = $dom->createElement('username');
     $usernameElement->appendChild($dom->createTextNode(API::encode($this->username)));
     $credentialsElement->appendChild($usernameElement);
     $passwordElement = $dom->createElement('password');
     $passwordElement->appendChild($dom->createTextNode(API::encode($this->password)));
     $credentialsElement->appendChild($passwordElement);
     $hashElement = $dom->createElement('hash');
     $hashElement->appendChild($dom->createTextNode(API::encode($this->hash)));
     $credentialsElement->appendChild($hashElement);
     if (isset($this->language)) {
         $languageElement = $dom->createElement('language');
         $languageElement->appendChild($dom->createTextNode($this->language));
         $credentialsElement->appendChild($languageElement);
     }
     if (isset($this->token)) {
         $tokenElement = $dom->createElement('token');
         $tokenElement->appendChild($dom->createTextNode($this->token));
         $credentialsElement->appendChild($tokenElement);
     }
     if (isset($this->ip)) {
         $ipElement = $dom->createElement('ip');
         $ipElement->appendChild($dom->createTextNode($this->ip));
         $credentialsElement->appendChild($ipElement);
     }
     if (isset($this->misc)) {
         $miscElement = $dom->createElement('misc');
         $credentialsElement->appendChild($miscElement);
         API::convertPhpObjToDom($this->misc, $miscElement, $dom);
     }
     $rootElement = $dom->createElement('openXML');
     $rootElement->appendChild($credentialsElement);
     $rootNode = $dom->appendChild($rootElement);
     $cmdNode = $rootNode->appendChild($dom->createElement($this->getCommand()));
     API::convertPhpObjToDom($this->args, $cmdNode, $dom);
     return $dom->saveXML();
 }
示例#2
0
 /**
  * Fetch the reply string
  *
  * @return string
  */
 public function getReply()
 {
     $dom = new DOMDocument('1.0', API::$encoding);
     $rootNode = $dom->appendChild($dom->createElement('openXML'));
     $replyNode = $rootNode->appendChild($dom->createElement('reply'));
     $codeNode = $replyNode->appendChild($dom->createElement('code'));
     $codeNode->appendChild($dom->createTextNode($this->faultCode));
     $descNode = $replyNode->appendChild($dom->createElement('desc'));
     $descNode->appendChild($dom->createTextNode(API::encode($this->faultString)));
     $dataNode = $replyNode->appendChild($dom->createElement('data'));
     API::convertPhpObjToDom($this->value, $dataNode, $dom);
     if (count($this->warnings) > 0) {
         $warningsNode = $replyNode->appendChild($dom->createElement('warnings'));
         API::convertPhpObjToDom($this->warnings, $warningsNode, $dom);
     }
     if (class_exists('sfConfig') && \sfConfig::get("app_system_maintenance")) {
         $maintenanceNode = $replyNode->appendChild($dom->createElement('maintenance'));
         $maintenanceNode->appendChild($dom->createTextNode(1));
     }
     return $dom->saveXML();
 }