Hello Richard,

Regarding the post HTTP method and the annotated methods server 
resources, I updated the header management in the JavaScript edition. 
The routing to such methods is based on the Content-Type header. I 
committed all my updates in GitHub, so feel free to make some tests and 
give me a feedback.

Be aware that there is a bug in Restlet 2.1 regarding the routing to the 
right methods. If a media isn't specified for the first method, this 
method will be used and it's not correct...

@Put
(...)

@Put("json")
(...)

It works with the following:

@Put("json")
(...)

@Put
(...)

This problem is about to be fixed in the Java version of Restlet.

Thierry

> Thanks again for your help.  I downloaded tcpmon and made the 
> suggested changes to my Java client.  I then did a post through Java 
> and below are the Request and the Response.
>
> Request....
> POST /commitments/ HTTP/1.1
> Date: Wed, 15 Feb 2012 22:19:58 GMT
> Content-Length: 109
> Content-Type: application/json; charset=UTF-8
> Accept: */*
> Host: localhost:8880
> User-Agent: Restlet-Framework/2.1rc2
> Cache-Control: no-cache
> Pragma: no-cache
> Connection: keep-alive
>
> {"id":0,"title":"Added through post - Java client","description":"This 
> is a description of post Java client"}
>
> Response...
> HTTP/1.1 200 OK
> Content-Type: application/json; charset=UTF-8
> Date: Wed, 15 Feb 2012 22:19:59 GMT
> Accept-Ranges: bytes
> Server: Restlet-Framework/2.1rc2
> Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
> Content-Length: 1
>
> 4
>
> Then I moved to the Javascript side.  I didn't install Firebug, but 
> instead I just changed the ClientResource creation from:
>   var clientResource = new ClientResource("/commitments/");  /
> To:
>   var clientResource = new 
> ClientResource("http://localhost:8880/commitments/";);
> where TCPmon was running on 8880 and forwarding to 8888, which is 
> where my server was listening.
>
> Below are the Request and Response - and they are definitely different 
> than the Java version...
>
> Request...
> OPTIONS /commitments/ HTTP/1.1
> Host: localhost:8880
> Connection: keep-alive
> Access-Control-Request-Method: POST
> Origin: http://localhost:8888
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 
> (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11
> Access-Control-Request-Headers: Origin, Content-Type, accept
> Accept: */*
> Referer: http://localhost:8888/oldTest.html
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: en-US,en;q=0.8
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
>
> Response...
> HTTP/1.1 200 OK
> Content-Type: application/vnd.sun.wadl+xml; charset=UTF-8
> Date: Wed, 15 Feb 2012 22:22:22 GMT
> Accept-Ranges: bytes
> Allow: POST, GET
> Server: Restlet-Framework/2.1rc2
> Transfer-Encoding: chunked
>
> 5D2
> <?xml version="1.0" standalone="yes"?>
> <?xml-stylesheet type="text/xsl" href="wadl2html.xslt"?>
> <application xmlns="http://wadl.dev.java.net/2009/02";>
> <doc title="Commitments resource"/>
> <representation id="commitment" mediaType="text/plain">
> <doc title="Commitment">Simple string containing the commitment ID</doc>
> </representation>
> <resources>
> <resource path="commitments/">
> <doc title="Commitments resource">The resource that contains the list 
> of commitments in the system</doc>
> <method name="GET">
> <response>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/></response>
> </method>
> <method name="POST">
> <request>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/></request>
> <response>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/>
> <representation href="#commitment"/></response>
> </method>
> </resource>
> </resources>
> </application>
>
> One small typo on the 
> http://templth.wordpress.com/2011/05/17/activating-tracing-mode-in-restlet/ 
> article, in the ClientResource section the line:
> Context context = clientResource.getContext();
> should be
> context = clientResource.getContext();
> (but this is minor - the ease of getting the trace using Restlet 
> tracing was awesome).
>
> Thanks again for all your assistance!  (And my apologies in advance if 
> the problem turns out to be some silly mistake in my code - always a 
> real possibility).
>
> RB

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2925370

Reply via email to