[jira] [Created] (OFBIZ-4274) Implement a REST Servlet

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
49 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13107750#comment-13107750 ]

Raj Saini commented on OFBIZ-4274:
----------------------------------

I am not the expert but one of my quick observation is RESTful responses should return HTTP status. HTTP response should be packaged as standard HTTP headers including status codes. http://restpatterns.org/HTTP_Status_Codes have lists of RESTful codes.

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13107755#comment-13107755 ]

Adrian Crum commented on OFBIZ-4274:
------------------------------------

Raj,

I apologize if the design description was not clear about HTTP status codes. Yes, of course HTTP status codes will be returned (since REST is nothing more than HTTP 1.1).

What I tried to describe is the HTTP status code behavior when an OFBiz service returns an error: The service error will not affect the HTTP status code. Instead, a 200 HTTP status will be returned and the response body will contain the result of the service call - which describes the error returned by the service.

The reason why OFBiz service errors are handled this way should be obvious from a web client perspective. If an OFBiz service returned an error and that error resulted in an HTTP error status being returned, then how would a web client (or developer) know what the service error was?


> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13107812#comment-13107812 ]

Raj Saini commented on OFBIZ-4274:
----------------------------------

Adrian,

Thanks for the clarification.

There are RESTful client APIs in Java and other framework and developers may want to take advantage of these APIs. These client API follow the RESTful standard and they may depend on the HTTP headers and statuses. If we plan to use the XML based packaging and error handing, it will become the responsibility of the developer to handle all standard application errors at application level instead of delegating it to application. Below is a code snippet consuming RESTful services using Oracle Jersey client API. Client API is trying to get the response status and I guess it is only possible if response is a standard.


WebResource webResource = client.resource("http://example.com/base");
ClientResponse response = webResource.accept("text/plain").get(ClientResponse.class);
int status = response.getStatus();
String textEntity = response.getEntity(String.class);





> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13107903#comment-13107903 ]

Adrian Crum commented on OFBIZ-4274:
------------------------------------

Raj,

I understand what you are saying, but the OFBiz service result does not provide enough information to affect the HTTP response headers. For example, if a user was not authorized to create a resource, then an HTTP status code of 403 should be returned. The problem is, OFBiz services do not categorize results that way - the results are either "success" or "error" - so there is no way for the servlet to map service responses to HTTP status codes. We could introduce a new service return type - like "not-authorized" or something similar, but that would involve rewriting all of the OFBiz services. There is no one-to-one mapping of OFBiz service results to HTTP response codes.

As far as web client development is concerned, OFBiz REST client skeleton code could be provided to make development easier. There is nothing in the code snippet you provided that would prohibit a developer from connecting the Oracle Jersey client API to an OFBiz REST client API:

{code}

OFBizRestClientRepresentation orcr = new OFBizRestClientRepresentation("xml");
WebResource webResource = client.resource("https://localhost:8443/example/services/example");
ClientResponse response = webResource.accept(orcr.getContentType()).get(ClientResponse.class);
orcr.setResponse(response);
if (orcr.success()) {
  // Process response
} else {
  // Process error
}

{code}



> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157974#comment-13157974 ]

Jacques Le Roux commented on OFBIZ-4274:
----------------------------------------

Hi,

Some weeks ago, I read this article http://www.javacodegeeks.com/2011/10/java-restful-api-integration-testing.html. Maybe it can help integration in OFBiz.
Googling for such today I found also http://code.google.com/p/rest-client/. Of course there are alot of other interesting results when Googling for "restful testing"

My 2 cts
               

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13159818#comment-13159818 ]

Jacques Le Roux commented on OFBIZ-4274:
----------------------------------------

Also Sascha tweeted this interesting article for load testing rest apps http://www.codeaffine.com/2011/11/28/stressload-testing-of-asynchronous-httprest-services-with-jmeter/
               

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274230#comment-13274230 ]

Jacques Le Roux commented on OFBIZ-4274:
----------------------------------------

Not directly related and not even to OFBiz, but for those interested by this issue here is an [article which pertains to REST|http://jee-bpel-soa.blogspot.fr/2012/05/cxf-jax-rs-on-apache-tomee.html?utm_source=twitterfeed&utm_medium=twitter]
               

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: RestExampleSchema.xsd, RestXmlRepresentation.xml, rest-conf.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13497656#comment-13497656 ]

Scott Gray commented on OFBIZ-4274:
-----------------------------------

I've only looked at rest-conf.xml at this stage but the following issues come to mind:
1. No support for sub-resources e.g. GET: /parties/10000/contactmechs/ While this could also be possible using contactmechs?partyId=10000, I don't think we should restrict APIs to a non-hierarchical structure.
2. I think it might be better to structure the document by resource with child elements for methods e.g.
{code:xml}
<resource name="example">
  <post>
    <security https="true" auth="true"/>
    <invoke-service name="createExample">
    <!--
      The servlet will convert trailing path elements into a List, so they can be queried by code.
    -->
      <service-param name="exampleId" value="${pathElements[0]}"/>
    </invoke-service>
    <response-hyperlink resource="exampleItem"/>
    <response-hyperlink url="http://www.mydomain.com"/>
  </post>
  <!-- Updates (or creates) an Example -->
  <put>
    <security https="true" auth="true"/>
    <invoke-service name="updateExample">
      <service-param name="exampleId" value="${pathElements[0]}"/>
    </invoke-service>
    <response-hyperlink resource="exampleItem"/>
  </put>
</resource>
{code}
3. I think we're also missing the distinction between collection and instance methods whereby GET: /party/ and GET:/party/10000 access different services and return different results.

That's all that comes to mind right now.
               

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: rest-conf.xml, RestExampleSchema.xsd, RestXmlRepresentation.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-4274) Implement a REST Servlet

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-4274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498019#comment-13498019 ]

Adrian Crum commented on OFBIZ-4274:
------------------------------------

Thank you for the review Scott!

I agree #1 would be nice to have, but I was trying to keep the initial implementation simple.

I like the XML structure you suggested - I will update the file and create a schema.

               

> Implement a REST Servlet
> ------------------------
>
>                 Key: OFBIZ-4274
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4274
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: rest-conf.xml, RestExampleSchema.xsd, RestXmlRepresentation.xml
>
>
> Implement a REST servlet that will map REST requests to OFBiz services. Details are in the comments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
123