I'm working on a project that might require accessing OFBiz services via
REST. I know there have been discussions about using Axis, and Chris
Snow was able to get a REST library to work with OFBiz. Please correct
me if I'm wrong, but it seems to me OFBiz already has most of what is
needed to implement REST, so there shouldn't be any need to use any
additional libraries.
From what I understand, REST services are simply HTTP requests sent to
a particular URL to invoke a particular service. The request response
contains any requested data in a format the REST client specified in the
request. The HTTP commands GET, POST, PUT, and DELETE are used in the
requests. The meaning of the REST HTTP commands are server-specific.
So here is what I'm thinking: Let's say we want to access OFBiz services
via REST. We don't need to support the PUT and DELETE commands because
the services themselves determine what actions will be performed on the
data. So, let's say that a GET command gets information about the
service, and the POST command invokes the service.
From my perspective, this could be implemented in two different ways: a
REST servlet or a REST view handler. In either case, the basic flow
would be something like:
1. Get service name from request URL, look up service model. If export
is false, return 404.
2. If service model auth is true, get credentials from HTTP header. If
no credentials, return 401. If credentials are found, attempt to log in
user. If login fails, return 401.
3. If command is GET, get Accept content type(s) from HTTP header, use
those to find a converter. Convert service model info to requested type
and put it in the response.
4. If command is POST, get content type from HTTP header, use that to
find a converter. Convert POST data to service parameters and invoke the
service. Get Accept content type(s) from HTTP header, use those to find
a converter. Convert service result to requested type and put it in the
response.
So, we could implement REST with existing artifacts - no additional
libraries are needed (except maybe for data conversions).
What do you think? I'm not a REST expert, so comments are welcome!
-Adrian