/**
  * Send XML-RPC message
  *
  * @param   webservices.xmlrpc.XmlRpcMessage message
  * @return  scriptlet.HttpScriptletResponse
  */
 public function send(XmlRpcMessage $message)
 {
     with($r = $this->_conn->create(new HttpRequest()));
     $r->setMethod(HttpConstants::POST);
     $r->setParameters(new RequestData($message->serializeData()));
     $r->setHeader('Content-Type', 'text/xml; charset=' . $message->getEncoding());
     $r->setHeader('User-Agent', 'XP Framework XML-RPC Client (http://xp-framework.net)');
     // Add custom headers
     $r->addHeaders($this->_headers);
     $this->cat && $this->cat->debug('>>>', $r->getRequestString());
     return $this->_conn->send($r);
 }
Ejemplo n.º 2
0
 /**
  * Format data for XmlRpc requests.
  *
  * XMLRPC Serialization is performed here. Params for XMLRPC are a bit different than simple post/get.
  * be sure to specify a methodName in $params.  The data will be auto-typed based on the Data type in PHP
  * If arrays have any non-numeric keys they will become <structs> If you wish to force a type you can do so by changing
  * the element to an array. See the example below.
  *
  * usage. $this->request('xml', array('data' => $bigArray, 'methodName' => 'getImages'));
  *
  * Data array Sample:
  *
  * $bigArray = array(
  *		'simpleString' => 'sample',	
  *		'integerVal' => 1,
  *		'doubleVal' => 3.145,
  * 		'forcedInt' => array('value' => '1', 'type' => 'int'),
  *		'arrayType' => array('value' => array(2, 3, 4), 'type' => 'array'),
  *	);
  *
  * Keep in mind that when coercing types bad things can happen, if you are incorrect in your assumptions.
  *
  * @return void
  **/
 protected function _formatXmlData($params)
 {
     if (!class_exists('Xml')) {
         App::import('Core', 'Xml');
     }
     $defaults = array('methodName' => '', 'data' => array());
     $params = array_merge($defaults, $params);
     $message = new XmlRpcMessage();
     $message->methodName = $params['methodName'];
     $message->setData($params['data']);
     $result = $message->toString();
     $this->_data = $result;
 }