cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jervis Liu (JIRA)" <>
Subject [jira] Commented: (CXF-758) POST with not body causes exception in REST service
Date Thu, 02 Aug 2007 07:40:52 GMT


Jervis Liu commented on CXF-758:

Below is the comment copied from cxf-dev mailing list:

In general, yes, any non-idempotent operations should not be required to have a body. But
when it comes to using JAX-WS Dispatch/Provider to implement a Restful service, its really
down to the semantics of Provider/Dispatch per spec. As the spec is not specific on this point,
we could extend CXF code to support empty body with POST. However in practical, it is not
very clear to me how this can be done. First, empty body does not equal to a null Source.
Secondly, an empty Source wont be always mapped to an empty body and vice versa. For example,
if I give Dispatch an empty Source by Source emptySource = new DomSource(), the underlying
transformer will create empty source Document using DocumentBuilder.newDocument() thus results
in a XML body with at least an XML declaration of <?xml version="1.0" standalone="no" encoding="UTF-8"?>.
Same thing occurs to the Provider side, for an empty body without an XML declaration, the
parser even wont be able to know the input is indeed an xml document.

I would say this is just the limitation of using JAX-WS Dispatch/Provider to implement a Restful
service. If this blocks you, you can try something else, for example, the HTTP binding for
Restful service.


> 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