XML-RPC, and a proof of concept that misuses the XML-Data serialization format to help parse REST XML responses
Nice to see XML-RPC is still in active use. The buzz these days is all about REST, but XML-RPC is still the easiest way to make widely-accessible web services (IMHO).
BTW, after talking this morning to Leonard Richardson about web services using REST and XML-RPC APIs, I implemented last month's XML-RPC idea - using the XML-RPC ("XML-Data"?) serialization format to encode the data returned by a REST API - in the PeopleAggregator API code, so now we have four ways of accessing the API:
- normal XML-RPC
- REST ("low church REST" - i.e. GET and POST HTTP methods, so you can debug the API in a browser) with a choice of output format:
-- XML (<response><success>true</success>...</response>)
-- JSON ({'success': true, ...})
-- XML-RPC's XML-Data (<methodResponse>...</methodResponse>)
I implemented it by getting xmlrpc.php to check the request method and input content type, and pass GET requests and POSTs with x-www-form-urlencoded content type through to the REST logic, leaving everything else to be handled by the IXR XML-RPC library.
- - -
Leonard and I were throwing around some ideas about standardising REST APIs, or making some sort of a descriptor language for them -- in Leonard's words, "making them all work the same, or parameterizing the axes on which they differ".
Here's something that occurred to me later: instead of describing XML with WSDL or some equivalent, you could write XSLT that would turn the XML output from a REST API into XML-Data, which could then be parsed down into a convenient data structure.
I don't expect that people will like it, because it combines technologies from warring communities - the minimalists will complain about the XSLT, the XML/RDF types won't like the use of XML-Data, and so on - but you have to admit: XSLT and XML-Data are the perfect tools to map between arbitrary XML formats and common data structures (arrays, structs, integers, strings and floats).
Update: To show that this method WORKS, and perhaps to act as a starting point for anyone who takes this seriously, I've made a proof of concept XSL transform that converts selected XML responses from Flickr into sensible XML-RPC responses. Download here:
(BTW - Danny Ayers' excellent XSLT example and Norm Walsh's great tutorial were very helpful here - this is my first time using XSLT.)