Using the RESTful Web Service plugin business logic can be exposed as a RESTful Web Service. The RESTful Web Service plugin does not contain any client side functions or properties, it is a 100% server side operating plugin.
To create a RESTful Web Service, create a form in a solution and add one or more of the following methods to the form:
In case the matching method for the specific HTTP operation (GET, POST, DELETE or PUT) does not exists on the form, an INTERNAL_SERVER_ERROR response (HTTP 500) will be generated.
RESTful Web Services are to be stateless. As subsequent requests to the RESTful Web Service API might be handled by different headless clients in the pool of clients configured for the plugin, do not use any state in between calls to the API. This means at least the following:
For the POST and PUT operation (resp. ws_create() and ws_update() methods), data has to be supplied in the body of the HTTP Request. If the content in the body of the HTTP Request is missing, a NO_CONTENT response will be generates (HTTP 204).
The supported Content-Types are JSON (application/json) and XML (application/xml). The Content-Type can be explicitly set in the header of the HTTP Request:
Content-Type: application/json; charset=utf-8
Content-Type: application/xml; charset=utf-8
Note: the charset is optional. If not specified, utf-8 will be assumed.
If no valid Content-Type is set, the plugin will try to establish the type of the content based on the first character of the content:
By default, the response will be encoded with the UTF-8 charset. If the HTTP Request specified a different encoding, that will be used instead. If the encoding of the response needs to be different than the request encoding, this can be specified in the HTTP Request by setting the charset value in the Accept header:
The RESTful Web service plugin currently does not support authentication.
To service the requests to the RESTful Web service API, the plugin creates a pool of (headless) clients. The maximum number of clients allowed can be set using the "rest_ws_plugin_client_pool_size" property of the plugin (default value = 5).
When there are more concurrent requests than the number of clients in the pool, by default the requests will wait until a client becomes available in the pool. This behavior can be altered by setting the "rest_ws_plugin_client_pool_exhausted_action" property of the plugin. The following values are supported for this property:
Servoy Cluster
The RESTful Web service plugin uses a pool of headless clients to service the requests. When operated within a Servoy Cluster, note that poolsize is set per Servoy Application Server.
A sample solution is included in the Servoy distribution (servoy_sample_rest_ws.servoy), detailing how to retrieve data from the http request and to return a response.
http://en.wikipedia.org/wiki/Representational_State_Transfer
http://www.infoq.com/articles/rest-introduction
http://www.ibm.com/developerworks/webservices/library/ws-restful/
http://home.ccil.org/~cowan/restws.pdf
Open source
This plugin is open source. The rest_ws.jar file in the <servoy>/application_server/plugins directory contains the source.
{column:width=80px}{column}{column}{column}
Server Property Summary
{column:width=100%}{column}
Server Property Details
Action when no more clients are availiable (block/fail/grow), default = block
Parameters
Returns
Also see
External links
Sample
Max number of clients used (this defines the number of concurrent requests and licences used), default = 5
Parameters
Returns
Also see
External links
Sample