cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conrad O'Dea (JIRA)" <>
Subject [jira] Commented: (CXF-758) POST with not body causes exception in REST service
Date Tue, 03 Jul 2007 06:55:08 GMT


Conrad O'Dea commented on CXF-758:

The same behaviour happens if I send a DELETE request.  For example, change the restful_dispatch
demo such that the query for a specific customer is a delete: 

        url = new URL(endpointAddress + "?id=1234");
        System.out.println("Invoking server through HTTP GET to query customer info");
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();

I think that this is indicative of a bug.  

Jervis, I tried your suggested workaround but it did not make any difference.  An XML element
has to be added after the prolog for it to work. 

In general, I don't think  all non-idempotent operations should be required to have a body.
 A Service may have operations that modify its state and therefore should not be GETable but
do not require any data.

> POST with not body causes exception in REST service
> ---------------------------------------------------
>                 Key: CXF-758
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Conrad O'Dea
> Sending a POST with an empty body to a RESTful service causes a 500 to be raised by the
> In the client for the restful_dispatch demo, change this line: 
>         InputStream in = url.openStream();
> to
>         HttpURLConnection conn = (HttpURLConnection)url.openConnection();
>         conn.setRequestMethod("PUT");
>         InputStream in = conn.getInputStream();
> and run the client against the server. 
> I get the following stack trace on the client: 
>      [java] Exception in thread "main" Server returned HTTP response
code: 500 for URL: http://localhost:9000/customerservice/customer
>      [java]     at
>      [java]     at demo.restful.client.Client.main(
>      [java] Java Result: 1
> and the following stack trace on the server 
>      [java] Jul 2, 2007 3:33:12 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
>      [java] INFO: Interceptor has thrown exception, unwinding now
>      [java] org.apache.cxf.interceptor.Fault: Could not parse the XML stream.
>      [java]     at
>      [java]     at
>      [java]     at
>      [java]     at org.apache.cxf.jaxws.interceptors.ProviderInDatabindingInterceptor.handleMessage(
>      [java]     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
>      [java]     at org.apache.cxf.transport.ChainInitiationObserver.onMessage(
>      [java]     at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(
>      [java]     at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(
>      [java]     at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
>      [java]     at org.mortbay.jetty.servlet.SessionHandler.handle(
>      [java]     at org.mortbay.jetty.handler.ContextHandler.handle(
>      [java]     at org.mortbay.jetty.handler.ContextHandlerCollection.handle(
>      [java]     at org.mortbay.jetty.handler.HandlerWrapper.handle(
>      [java]     at org.mortbay.jetty.Server.handle(
>      [java]     at org.mortbay.jetty.HttpConnection.handleRequest(
>      [java]     at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(
>      [java]     at org.mortbay.jetty.HttpParser.parseNext(
>      [java]     at org.mortbay.jetty.HttpParser.parseAvailable(
>      [java]     at org.mortbay.jetty.HttpConnection.handle(
>      [java]     at
>      [java]     at org.mortbay.thread.BoundedThreadPool$
>      [java] Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
>      [java]  at [row,col {unknown-source}]: [1,0]
>      [java]     at
>      [java]     at
>      [java]     at
>      [java]     at
>      [java]     at org.apache.cxf.staxutils.StaxUtils.readDocElements(
>      [java]     at
>      [java]     at
>      [java]     ... 20 more

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message