You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Conrad O'Dea (JIRA)" <ji...@apache.org> on 2007/07/02 16:35:04 UTC

[jira] Created: (CXF-758) POST with not body causes exception in REST service

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.


[jira] Commented: (CXF-758) POST with not body causes exception in REST service

Posted by "Dan Diephouse (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509621 ] 

Dan Diephouse commented on CXF-758:
-----------------------------------

Wouldn't a POST on a Provider kind of imply that there should be an XML body? I wouldn't be surprised if that was even part of the JAX-WS spec.

> 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.


[jira] Commented: (CXF-758) POST with not body causes exception in REST service

Posted by "Jervis Liu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509743 ] 

Jervis Liu commented on CXF-758:
--------------------------------

Just checked spec, does not say anything about this.  For all the valid input formats that can be used for SOAP binding (Source/SOAPMessage/JAXBElement), obviously you cant send a POST with an empty body, you need an empty soap message at least. For XML/HTTP binding, I am not sure what is a valid "empty" xml body. I presume sending sth like below should be valid: <?xml version="1.0" encoding="UTF-8"?>. Thoughts?



> 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.


[jira] Commented: (CXF-758) POST with not body causes exception in REST service

Posted by "Conrad O'Dea (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517167 ] 

Conrad O'Dea commented on CXF-758:
----------------------------------

Hi Jervis, 

thanks for the information....good points.  However, this used to work.  Not sure why it was changed but in an earlier version of CXF there was no problem having a Provider handle a POST with an empty body. 

This is not a blocker.  

thanks
Conrad 


> 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.


[jira] Commented: (CXF-758) POST with not body causes exception in REST service

Posted by "Conrad O'Dea (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509764 ] 

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();
        conn.setRequestMethod("DELETE"); 

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: 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.


[jira] Commented: (CXF-758) POST with not body causes exception in REST service

Posted by "Jervis Liu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517165 ] 

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.

Cheers,
Jervis

> 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.