POST request from a REST client will cause a NullPointerException in the service
--------------------------------------------------------------------------------
Key: AXIS2-787
URL: http://issues.apache.org/jira/browse/AXIS2-787
Project: Apache Axis 2.0 (Axis2)
Type: Bug
Components: core
Versions: 1.0
Reporter: Kent Tong
In RESTUtil.java in the processPostRequest() method:
msgContext.setEnvelope(soapEnvelope);
msgContext.setProperty(HTTPConstants.HTTP_METHOD,
HTTPConstants.HTTP_METHOD_POST);
msgContext.setProperty(HTTPConstants.CONTENT_TYPE, contentType);
msgContext.setDoingREST(true);
It seems that an extra line should be add:
msgContext.setEnvelope(soapEnvelope);
msgContext.setProperty(HTTPConstants.HTTP_METHOD,
HTTPConstants.HTTP_METHOD_POST);
msgContext.setProperty(HTTPConstants.CONTENT_TYPE, contentType);
msgContext.setDoingREST(true);
//ADD THIS LINE
msgContext.setProperty(MessageContext.TRANSPORT_OUT,
response.getOutputStream());
Otherwise the TRANSPORT_OUT is not set and the service won't be able to output
the response, producing a stack trace like:
java.lang.NullPointerException
at java.io.Writer.<init>(Writer.java:70)
at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:79)
at
org.apache.axiom.om.impl.MTOMXMLStreamWriter.<init>(MTOMXMLStreamWriter.java:74)
at
org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:380)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:256)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:210)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:589)
at
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:43)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)
at
org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:150)
at
org.apache.axis2.transport.http.util.RESTUtil.processPostRequest(RESTUtil.java:100)
at
org.apache.axis2.transport.http.AxisRESTServlet.doPost(AxisRESTServlet.java:43)
For the moment actually the response argument is not used at all in the
processPostRequest() method. In contrast, the processPostRequest() method does
perform this step.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]