Recent blog posts
- DrupalCamp CA / Guatemala 2010
- Content Profile Form inside User Edit for Drupal 6
- How use views arguments in PHP Code for Drupal 6
- Drupal Contribution: Generate vancode using mysql alone
- Drupal Module Patch: Belated PNG
- Drupal Patch to Notify Module to process only new content
- Notify module: Handle both published and unpublished entries
- osCommerse Authentication | New Drupal Module
- Single Sign On between Drupal and Moodle
- Share SSH Public Key Authentication
Reply to comment
Submitted by enzo on Wed, 10/21/2009 - 12:36
Getting information accross XML-RPC
Hello folks, this is my weekly contribution to QCubed project a new XML-RPC client plugin.
QXmlRpc_Client provides a client for XML-RPC based web services, as defined in this specification. If the server you need to talk to responds to XML-RPC, you'll save yourself a bunch of time if you use this plugin.
To look into how the plugin works in detail, let's consider a sample web service defined at http://phpxmlrpc.sourceforge.net/server.php?methodName=examples.getStateName. This example is really simple: given a number from 1 to 51, the service returns the name of the USA state that has that "id". If you enter a number outside of that range, the service returns an error. Go ahead and experiment with it at http://examples.qcu.be/assets/plugins/QXmlRpcClient/example/qxmlrpc_client.php.
Let's now look at how to use the client. It's really straightforward - first, initialize a QXmlRpc_Client object. Then, create an array of parameters that you want to pass to the web service. Each parameter has to be wrapped with a QXmlRpc_Client::prepare() call to format the parameters appropriately.
$aParams = array( QXmlRpc_Client::prepare((int) $this->txtState->Text) ); Then, make the actual request - note that requests are synchronous (i.e. execution will go to the next line of code after you get the actual response). That said, if you are making the call in a QAjaxAction, the QForm will still be responsive to the user.
list($success, $response) = $client->request(
'phpxmlrpc.sourceforge.net', // server name
'/server.php', // server endpoint
'examples.getStateName',// method name
$aParams // parameters that we prepared above );
Result of making a request is a key-value pair. The first variable is a boolean that indicates success or failure; the second one is an array with the details.
Enjoy it.

