Welcome Guest, Not a member yet? Register   Sign In
Associative array as request-data in XML-RPC request
#3

[eluser]gtech[/eluser]
I have to say this was a complete head bender to get working, but after reading the code I got the following to work

Client:
Code:
<?php

class Xmlrpc_client extends Controller {
    
    function index()
    {    
        $this->load->helper('url');
        $server_url = site_url('xmlrpc_server');
    
        $this->load->library('xmlrpc');

        
        $this->xmlrpc->server($server_url, 80);
        $this->xmlrpc->method('Greetings');

        $this->xmlrpc->request(array(
                                    array(
                                          // Param 0
                                          array('test'=>'testdata'),
                                          'struct'
                                    ),
                                    array(
                                          // Param 1
                                          array('var1'=>'testdata2',
                                                'var2'=>'testdata3'),
                                          'struct'
                                    )
                               ),
                               'struct');        

        if ( ! $this->xmlrpc->send_request())
        {
            echo $this->xmlrpc->display_error();
        }
        else
        {
            echo '<pre>';
            print_r($this->xmlrpc->display_response());
            echo '</pre>';
        }
    }
}
?&gt;

Server:
Code:
&lt;?php

class Xmlrpc_server extends Controller {

  function index()
  {
    $this->load->library('xmlrpc');
    $this->load->library('xmlrpcs');
        
    $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server._process');
        
    $this->xmlrpcs->initialize($config);
    $this->xmlrpcs->serve();
  }
    
    
  function _process($request)
  {
    $parameters = $request->output_parameters();
    $response = array(
                     array(
                          'you_said'  => $parameters['0']['test'],
                          'you_said2'  => $parameters['1']['var1'],
                          'you_said3'  => $parameters['1']['var2'],
                          'i_respond' => 'Not bad at all.'
                     ),
                'struct');
    return $this->xmlrpc->send_response($response);
  }
}
?&gt;

enjoy Smile


Messages In This Thread
Associative array as request-data in XML-RPC request - by El Forum - 06-10-2008, 05:31 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 02:31 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 07:07 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 07:25 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 07:36 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 08:01 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 08:09 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 08:18 AM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 03:32 PM
Associative array as request-data in XML-RPC request - by El Forum - 06-11-2008, 04:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB