REpresentational State Transfer (REST) is an architectural style for distributed systems in general and web services in particular. As an alternative for traditional SOAP/WSDL web services, it has drawn a lot of attention recently. The main advantage of RESTful web services is their natural simplicity. Here web service functions are same as the HTTP ‘verbs’ which are applied to different resources which have different URLs . More information on the REST style is available e.g. at Wikipedia
In order to provide the RESTful web service facility in any computing environment, one has to provide a function for each of the HTTP verbs. In MXQuery, we have adopted the approach taken by Zorba. Detailed signature of the REST functions are described in the Zorba documentation. The main difference is that MXQuery does not support the additional tidy options, since the HTML cleaner works differently.
In order to use REST functionality, the module
"http://www.zorba-xquery.com/zorba/rest-functions"
has to be included at the beginning of the query.
Examples:
Invoke a “GET”
import module namespace zorba-rest = "http://www.zorba-xquery.com/zorba/rest-functions";
let $result := zorba-rest:get("http://tidy.sourceforge.net/docs/quickref.html") let $payload := $result//zorba-rest:payload return $payload
Invoke a “POST” with a payload
import module namespace zorba-rest = "http://www.zorba-xquery.com/zorba/rest-functions";
zorba-rest:post('http://serveraddress:port/RestSOAPTestServer/RestParamTest', <payload>123456</payload>)