I have been a little frustrated with trying to get outside applications to consume services. The services browser is invaluable in testing the services themselves but fails in helping test the servers. For instance, if I do a views.get in the service, it returns an array (php) with node references. When I try the JSON server module, it does not return the node references. Are there any recommendations on how to test different service functions out through JSON? I though that a PHP file could be written to do this, but I wanted to see if anything out there exists alreay.
2 Answers
I found a module called Web Service Clients. It is still unstable, but it works.
Parallel to the Services module, the Clients module provides the ability to implement pluggable clients to external web services, including external Drupal sites running the Services module, the main use case being ingesting content from other Drupal installs via the Services module XMLRPC server.
/Load xmlrpc library
require_once('XmlRPC.php');
//Define Facekard server host
$facekard_server = 'localhost';
//Define facekard api server path
$facekard_server_path = '/wsdl/test/services';
//Make connection to server
$connection = new XmlRPC($facekard_server,$facekard_server_path);
//die(print_r($connection));
//Call remote function system.connect to get session id
$system_connect = $connection->call('system.connect');
//die(print_r($system_connect));
//Fetch sessid from xml object
$session_id = $system_connect->sessid;
$pass = '123456';
-
1Hi Tan, welcome to DA. Although the code looks sound, it'd be great to see an explanation as to what it's doing so it might help other users or less-experienced Drupalers :)– ChapabuCommented Oct 21, 2012 at 14:05