/** * {@inheritdoc} */ public function parse($xmlString, &$isFault) { $result = xmlrpc_decode($xmlString, 'UTF-8'); $isFault = false; $toBeVisited = [&$result]; while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) { $type = gettype($value); if ($type === 'object') { $xmlRpcType = $value->{'xmlrpc_type'}; if ($xmlRpcType === 'datetime') { $value = DateTime::createFromFormat('Ymd\\TH:i:s', $value->scalar, isset($timezone) ? $timezone : ($timezone = new DateTimeZone('UTC'))); } elseif ($xmlRpcType === 'base64') { if ($value->scalar !== '') { $value = Base64::serialize($value->scalar); } else { $value = null; } } } elseif ($type === 'array') { foreach ($value as &$element) { $toBeVisited[] =& $element; } } array_shift($toBeVisited); } if (is_array($result)) { reset($result); $isFault = xmlrpc_is_fault($result); } return $result; }
/** @dataProvider getClients */ public function testBase64(CallClientInterface $client) { $expected = fXmlRpc\Value\Base64::serialize('HELLO WORLD'); $result = $client->call('system.echo', array($expected)); $this->assertSame($expected->getEncoded(), $result->getEncoded()); $this->assertSame($expected->getDecoded(), $result->getDecoded()); }
/** {@inheritdoc} */ public function parse($xmlString) { if ($this->validateResponse) { XmlChecker::validXml($xmlString); } $result = xmlrpc_decode($xmlString, 'UTF-8'); if ($result === null && self::isBiggerThanParseLimit($xmlString)) { throw ParserException::xmlrpcExtensionLibxmlParsehugeNotSupported(); } $toBeVisited = [&$result]; while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) { $type = gettype($value); if ($type === 'object') { $xmlRpcType = $value->{'xmlrpc_type'}; if ($xmlRpcType === 'datetime') { $value = DateTime::createFromFormat('Ymd\\TH:i:s', $value->scalar, isset($timezone) ? $timezone : ($timezone = new DateTimeZone('UTC'))); } elseif ($xmlRpcType === 'base64') { if ($value->scalar !== '') { $value = Base64::serialize($value->scalar); } else { $value = null; } } } elseif ($type === 'array') { foreach ($value as &$element) { $toBeVisited[] =& $element; } } array_shift($toBeVisited); } if (is_array($result)) { reset($result); if (xmlrpc_is_fault($result)) { throw FaultException::fault($result); } } return $result; }
public function encodeImage($aImage) { return array('filename' => $aImage['filename'], 'content' => \fXmlRpc\Value\Base64::serialize($aImage['content']), 'editswf' => !empty($aImage['editswf'])); }
public function provideTypes() { return array(array('string', 'test string', 'test string'), array('int', 2, '2'), array('int', -2, '-2'), array('double', 1.2, '1.2'), array('double', -1.2, '-1.2'), array('boolean', true, '1'), array('boolean', false, '0'), array('dateTime.iso8601', DateTime::createFromFormat('Y-m-d H:i:s', '1998-07-17 14:08:55', new DateTimeZone('UTC')), '19980717T14:08:55'), array('base64', Base64::serialize('string'), "c3RyaW5n\n"), array('string', 'Ümläuts', 'Ümläuts')); }