POST with not body causes exception in REST service
---------------------------------------------------
Key: CXF-758
URL: https://issues.apache.org/jira/browse/CXF-758
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 server.
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" java.io.IOException: Server returned
HTTP response code: 500 for URL: http://localhost:9000/customerservice/customer
[java] at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1152)
[java] at demo.restful.client.Client.main(Client.java:66)
[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
org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:96)
[java] at
org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:86)
[java] at
org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:48)
[java] at
org.apache.cxf.jaxws.interceptors.ProviderInDatabindingInterceptor.handleMessage(ProviderInDatabindingInterceptor.java:103)
[java] at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:206)
[java] at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:67)
[java] at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:253)
[java] at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:213)
[java] at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:54)
[java] at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[java] at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
[java] at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
[java] at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
[java] at org.mortbay.jetty.Server.handle(Server.java:281)
[java] at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
[java] at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:821)
[java] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
[java] at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
[java] at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
[java] at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368)
[java] at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
[java] Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in
prolog
[java] at [row,col {unknown-source}]: [1,0]
[java] at
com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:661)
[java] at
com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2134)
[java] at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2040)
[java] at
com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
[java] at
org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:663)
[java] at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:518)
[java] at
org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:93)
[java] ... 20 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.