/**
  * Construct a XML-RPC message from a string
  *
  * <code>
  *   $msg= XmlRpcRequestMessage::fromString('<methodCall>...</methodCall>');
  * </code>
  *
  * @param   string string
  * @return  webservices.xmlrpc.XmlRpcMessage
  */
 public static function fromString($string)
 {
     $msg = new XmlRpcRequestMessage();
     $msg->tree = \xml\Tree::fromString($string);
     // Set class and method members from XML structure
     $target = $msg->tree->root()->nodeAt(0)->getContent();
     list($msg->class, $msg->method) = explode('.', $target);
     return $msg;
 }
 /**
  * Run tests and return XML generated
  *
  * @param   unittest.TestCase... tests
  * @return  xml.Tree the output
  * @throws  unittest.AssertionFailedError in case the generated XML is not well-formed
  */
 protected function runTests()
 {
     foreach (func_get_args() as $test) {
         $this->suite->addTest($test);
     }
     $this->suite->run();
     try {
         return Tree::fromString($this->out->getBytes());
     } catch (\xml\XMLFormatException $e) {
         $this->fail('XML generated is not well-formed: ' . $e->getMessage(), $this->out->getBytes(), null);
     }
 }
 /**
  * Construct a XML-RPC response message from a string
  *
  * <code>
  *   $msg= XmlRpcResponseMessage::fromString('<methodCall>...</methodCall>');
  * </code>
  *
  * @param   string string
  * @return  webservices.xmlrpc.XmlRpcResponse Message
  */
 public static function fromString($string)
 {
     $msg = new self();
     $msg->tree = \xml\Tree::fromString($string);
     if (!$msg->tree->root()->hasChildren()) {
         throw new \lang\FormatException('Response is not well formed');
     }
     // Set class and method members from XML structure
     $target = $msg->tree->root()->nodeAt(0)->getContent();
     @(list($msg->class, $msg->method) = explode('.', $target));
     return $msg;
 }
 /**
  * Decode xml
  *
  * @param   string xml
  * @return  mixed
  */
 protected function decode($xml)
 {
     return create(new XmlRpcDecoder())->decode(Tree::fromString('<?xml version="1.0" encoding="utf-8"?><value>' . $xml . '</value>')->root());
 }
 public function fromNonXmlString()
 {
     Tree::fromString('@@NO-XML-HERE@@');
 }
 /**
  * Construct a SOAP message from a string
  *
  * <code>
  *   $msg= SOAPMessage::fromString('<SOAP-ENV:Envelope>...</SOAP-ENV:Envelope>');
  * </code>
  *
  * @param   string string
  * @return  xml.Tree
  */
 public static function fromString($string, $c = __CLASS__)
 {
     return parent::fromString($string, $c);
 }
Esempio n. 7
0
 /**
  * Create a WddxMessage object from an XML document.
  *
  * @param   string string
  * @return  webservices.wddx.WddxMessage
  */
 public static function fromString($string)
 {
     return parent::fromString($string, 'WddxMessage');
 }
 public function queryTreeWithEncoding()
 {
     $value = new String('value öäü', 'iso-8859-1');
     $xpath = new XPath(Tree::fromString(sprintf('<?xml version="1.0" encoding="iso-8859-1"?>' . '<document><node>%s</node></document>', $value->getBytes('iso-8859-1'))));
     $this->assertEquals($value, new String($xpath->query('string(/document/node)'), 'utf-8'));
 }
Esempio n. 9
0
 public function queryTreeWithEncoding()
 {
     $xpath = new XPath(Tree::fromString(sprintf('<?xml version="1.0" encoding="iso-8859-1"?>' . '<document><node>%s</node></document>', utf8_decode('öäü'))));
     $this->assertEquals('öäü', $xpath->query('string(/document/node)'));
 }