Hi,
I wrote a Restlet service by using restlet 1.1.8. It works fine when client
calls GET/PUT/DELETE. But I encountered exceptions when client calls POST.
I set the server returned status as 4xx, for example,
getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN) in the
acceptedRepresentation(Representation) method. The strange thing is the client
calling POST works fine only at first time after server restarts, and then
client encountered exceptions if calling POST after that. The exception happens
when running “Response response = c.handle(request);” which can be seen from
the following client code.
Any idea?
Thanks a lot,
Nicho
The exceptions are:
WARNING: An error occured during the communication with the remote HTTP server.
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at
com.noelios.restlet.http.ChunkedOutputStream.close(ChunkedOutputStream.java:100)
at
com.noelios.restlet.http.HttpClientCall.sendRequest(HttpClientCall.java:453)
at
com.noelios.restlet.http.StreamClientCall.sendRequest(StreamClientCall.java:360)
at
com.noelios.restlet.http.HttpClientConverter.commit(HttpClientConverter.java:417)
at
com.noelios.restlet.http.HttpClientHelper.handle(HttpClientHelper.java:108)
at org.restlet.Client.handle(Client.java:158)
at org.restlet.Uniform.handle(Uniform.java:108)
at uk.ngs.ca.server.ClientRun.post(ClientRun.java:80)
at uk.ngs.ca.server.ClientRun.main(ClientRun.java:209)
my part of client code:
Client c = new Client(Protocol.HTTP);
Request request = new Request(Method.POST, new
Reference(“http://localhost:8182/CA”), getRepresentation());
Response response = c.handle(request);
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2463916