Пример #1
0
 private function sendRequest($method, $args)
 {
     $request = new SXmlRpcRequest($method, $args);
     $headers = array("Content-Type: text/xml", "User-Agent: {$this->userAgent}", "Content-length: " . $request->length());
     $client = new SHttpClient($this->uri, $headers);
     $response = $client->post($request->toXml());
     if ($response->code != 200) {
         throw new SXmlRpcClientException("Request failed with code {$response->code}");
     }
     return $this->parseResponse($response->body);
 }
    public function testRequestToXml()
    {
        $req = new SXmlRpcRequest('test.myMethod', array('hello world', true, 12));
        $xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>test.myMethod</methodName>
<params>
<param><value><string>hello world</string></value></param>
<param><value><boolean>1</boolean></value></param>
<param><value><int>12</int></value></param>
</params>
</methodCall>
EOD;
        $this->assertDomEqual($xml, $req->toXml());
    }