Services: dynamically changing the returning server?

Events happening in the community are now at Drupal community events on www.drupal.org.
sime's picture

Look at the services architecture, a service is defined in such a way that it receives and sends data independently of the server involved.

I've been writing a "GET" server (some might call it a REST server, but there's semantic baggage that comes with REST that I don't care for). The GET server simply allows parameters to be passed on the url query string ie. in the path.

The call side is quite fine, but I was quite uncertain about how to return the data, it seemed to me that a number of ways are possible. In the end it was quite clear to me that if services return data independently, then I should be able to piggy-back on another server - return the data using amfphp or json or whatever.

One thing I will note, at the moment, it's literally impossible to change the server if it's already been set since the services function services_set_server_info() does nothing if $info has already been set. Is this on purpose?

Secondly, I'm not sure if json_server is doing it right, then again I am a schmuck - it does call services_call_method() (sorry, dmitrig01, I got that fact wrong in IRC), which returns the data for display, then json_server renders it as json within the same function. The other servers seem to use a callback system which I've been unable to figure out so far. I'm not altogether sure where to go from here. Should json_server use a callback too? Should what I'm doing work with xmlrpc?

Comments please.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/get_server/

Comments

Hmm. Hold on I seem to be

sime's picture

Hmm. Hold on I seem to be making progress.

I can't just call on the other servers, but it seems quite possible just to use xmlrpc_value_get_xml() and drupal_to_js(array('#error' => FALSE, '#data' => $result));. That's 2/3 pretty easily, nice.