HTTPClient($host, $port); $this->setRequestMethod("POST"); $this->addRequestHeaderRaw("Content-type: text/xml"); $this->xml = new XML("methodCall"); $this->xml->setTagContent("", "methodCall/methodName"); $this->xml->setTagContent("", "methodCall/params"); $this->xmlDoc = new XMLDocument(); $this->xmlDoc->setXML($this->xml); $paramsBranchArray = &$this->xml->getBranches("methodCall", "params"); $this->params = &$paramsBranchArray[0]; // this call not necessary if we can somehow update body before HTTPClient->sendRequest $this->setRequestBody($this->xmlDoc->getXMLString()); } /** * Adds a parameter to a method call in XMLRPC request * @method addParam * @param string paramType * @param mixed paramValue * @returns none */ function addParam($paramType, $paramValue) { $newParam = new XMLBranch("param"); $newParam->setTagContent($paramValue, "param/value/$paramType"); $this->params->addXMLBranch($newParam); // this call not necessary if we can somehow update body before HTTPClient->sendRequest $this->setRequestBody($this->xmlDoc->getXMLString()); } /** * Sets method name in XMLRPC request * @method setMethodName * @param string methodName * @returns none */ function setMethodName ($methodName) { $this->xml->setTagContent($methodName, "methodCall/methodName"); // this call not necessary if we can somehow update body before HTTPClient->sendRequest $this->setRequestBody($this->xmlDoc->getXMLString()); } /** * Sets XMLRPC request by supplying an XMLDocument object * @method setRequestXML * @param object XMLDocument * @returns true if successful, false otherwise */ function setRequestXML(&$XMLDocument) { if(is_object($XMLDocument) && strtolower(get_class($XMLDocument)) == "xmldocument") { $this->xmlDoc = &$XMLDocument; $this->xml = &$this->xmlDoc->getXML(); $this->params = &$this->xml->getBranches("methodCall", "params"); // this call not necessary if we can somehow update body before HTTPClient->sendRequest $this->setRequestBody(htmlspecialchars($this->xmlDoc->getXMLString())); $success = true; } else $success = false; return $success; } } ?>