Welcome Guest, Not a member yet? Register   Sign In
XML-RPC and https issues
#1

[eluser]cgeisel[/eluser]
Using the example code from the User Guide, I made an XMLRPC client and server, uploaded them to my CI (v1.7.1) install on my client's https server, and when I run the client code, I get the following error message and debug output:

Code:
---DATA---
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
&lt;html&gt;&lt;head>
&lt;title&gt;400 Bad Request&lt;/title&gt;
&lt;/head&gt;&lt;body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
Instead use the HTTPS scheme to access this URL, please.<br />
<blockquote>Hint: <a href="https://scrapit.ca/"><b>https://scrapit.ca/</b></a></blockquote></p>
&lt;/body&gt;&lt;/html>

---END DATA---

The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.

Here is the client code:

Code:
&lt;?php

class Xmlrpc_client extends Controller {

  function index()
  {
    $this->load->helper('url');
    $server_url = site_url('xmlrpc_server');

    $this->load->library('xmlrpc');
    $this->xmlrpc->set_debug(TRUE);

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

    $request = array('How is it going?');
    $this->xmlrpc->request($request);

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

and here is the server code:

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'],
          'i_respond' => 'Not bad at all.'),
        'struct');

    return $this->xmlrpc->send_response($response);
  }
}
?&gt;

What I don't understand is why the server thinks I'm not using the "https" scheme. If I echo the value of
Code:
$server_url
in my client, it's there.
#2

[eluser]cgeisel[/eluser]
Some additional information: if I set $server_url manually, the behavior is the same.

Also, if I set $server_url and use "http" as the scheme, the behavior is the same.

This suggests that regardless of which scheme I specify, the XML-RPC library is using http.
#3

[eluser]Unknown[/eluser]
Having the exact same problem here....
#4

[eluser]cgeisel[/eluser]
I discovered elsewhere that the library in question doesn't support SSL at this time. And also decided that XML-RPC has too much overhead to make it worthwhile for my project.

I ended up going with a REST server, written by Phil Sturgeon for CI. Link to tutorial:
http://net.tutsplus.com/tutorials/php/wo...igniter-2/

A link to download the server/libraries is in the tutorial. Good luck!




Theme © iAndrew 2016 - Forum software by © MyBB