• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse XML-RPC Server Response

I've been testing the XML-RPC CodeIgniter class, it's pretty good, buy i don't
have any idea of how the parse the response i get from the webservice server.

I'm using the sample code given in the documentation to create server and client:


// The Server
    public function xml_server() {
        $config['functions']['] = array('function'     => 'Welcome.echo_back);

        $config['object'] = $this;

    // The Client
    public function xml_client() {
        $this->xmlrpc->server('http://localhost/scripts/ci_rest/client/index.php/welcome/xml_server/', 80);

        $request = array('Message from Sov', 'Hi dude');

        if ( ! $this->xmlrpc->send_request())
            echo $this->xmlrpc->display_error();
            echo '<hr>';
            echo '<pre>';
            echo '</pre>';
    // The XML Response Function
    public function echo_back($request) {
        $parameters = $request->output_parameters();

        $response = array(
                                    'You sent to me:'  => $parameters['0'],
                                    'And: '                  => $parameters['1']),

        return $this->xmlrpc->send_response($response);

With the above example, it shows the response received from the server, buy i would like to know how to store the response in a array or some variables.

The XML-RPC client print this to the browser:

[you_said] => Hi dude?
[i_respond] => Hi there friend.

How do i store that values in a variable?

I tried like this:

$r = $this->xmlrpc->display_response();
$d = xmlrpc_decode($r['[you_said]']);

But doesn't works.

Is that possible? Sorry if it's a newbie question, but im new to this protocol.

I already done it using a foreach loop:

$r = $this->xmlrpc->display_response();

            foreach ($r as $y=>$value) {
                echo 'segment1: (' . $y . ') and segment2: (' . $value .')<br />';

It works fine, but if anyone knows another way, please tell it.

Nobody knows an alternative to do this?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.