You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Jason Kania (JIRA)" <ji...@apache.org> on 2007/07/24 15:29:35 UTC

[jira] Created: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

RESTful services invocation self induces Input Stream Closed error
------------------------------------------------------------------

                 Key: AXIS2-3007
                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
    Affects Versions: 1.2
         Environment: Windows 2000, Eclipse IDE
            Reporter: Jason Kania


When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.

ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
...

In RESTUtil, method processURLRequest, the following call is made on line 98
                soapEnvelope = TransportUtils
                        .createSOAPMessage(msgContext, null, contentType);
where the null is supposed to be the input stream

Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
            PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);

where inputStream is null,

the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
of ApplicationXMLBuilder:
           if ((b = pushbackInputStream.read()) > 0) {

For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Keith Godwin Chapman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515633 ] 

Keith Godwin Chapman commented on AXIS2-3007:
---------------------------------------------

fixed in revision 559737. Commited to both trunk and branch.  

Jason can you check the latest nightly.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Issue Comment Edited: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515450 ] 

Jason Kania edited comment on AXIS2-3007 at 7/25/07 4:03 PM:
-------------------------------------------------------------

I have investigated and two potential issues exist. The source of the incorrect content type is actually from the ServiceClient because within TransportUtils in method getMessageFormatter, it defaults content-type to application/xml when REST is enabled. I am not sure whether this default being set makes sense given your previous comments.

TransportUtils.getMessageFormatter(MessageContext) line: 249	
HTTPSender.populateCommonProperties(MessageContext, URL, HttpMethodBase, HttpClient, String) line: 254	
HTTPSender.sendViaGet(MessageContext, URL, String) line: 89	
HTTPSender.send(MessageContext, URL, String) line: 59	
CommonsHTTPTransportSender.writeMessageWithCommons(MessageContext, EndpointReference, OMOutputFormat) line: 305	
CommonsHTTPTransportSender.invoke(MessageContext) line: 201	
AxisEngine.send(MessageContext) line: 452	
OutInAxisOperationClient.send(MessageContext) line: 330	
OutInAxisOperationClient.execute(boolean) line: 294	
...

Subsequently, I followed the call stack on the servlet side up and the content-type was not changed. Thus, reproduction of the error should be as simple as setting up the client as follows:

ServiceClient serviceClient = new ServiceClient();
OperationClient client = serviceClient.createClient( ServiceClient.ANON_OUT_IN_OP );
Options options = new Options();
options.setTransportInProtocol( Constants.TRANSPORT_HTTP );

serviceClient.setTargetEPR( targetEPR );

options.setProperty( Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE ); // Thise seems to do nothing
options.setProperty( HTTPConstants.AUTHENTICATE, null );
options.setProperty( Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET );

MessageContext messageContext = new MessageContext();
messageContext.setIsSOAP11Explicit( false );
messageContext.setDoingREST( true );
client.addMessageContext( messageContext );

client.execute(true);

To me, this means that the Axis2 servlet should protect itself earlier on by detecting the invalid/unsupported content-type in the GET message.

Let me know if you need other information.



 was:
I have investigated and two potential issues exist. The source of the incorrect content type is actually from the ServiceClient because within TransportUtils in method getMessageFormatter, it defaults content-type to application/xml when REST is enabled. I am not sure whether this default being set makes sense given your previous comments.

TransportUtils.getMessageFormatter(MessageContext) line: 249	
HTTPSender.populateCommonProperties(MessageContext, URL, HttpMethodBase, HttpClient, String) line: 254	
HTTPSender.sendViaGet(MessageContext, URL, String) line: 89	
HTTPSender.send(MessageContext, URL, String) line: 59	
CommonsHTTPTransportSender.writeMessageWithCommons(MessageContext, EndpointReference, OMOutputFormat) line: 305	
CommonsHTTPTransportSender.invoke(MessageContext) line: 201	
AxisEngine.send(MessageContext) line: 452	
OutInAxisOperationClient.send(MessageContext) line: 330	
OutInAxisOperationClient.execute(boolean) line: 294	
...

Subsequently, I followed the call stack on the servlet side up and the content-type was not changed. Thus, reproduction of the error should be as simple as setting up the client as follows:

ServiceClient serviceClient = new ServiceClient();
OperationClient client = serviceClient.createClient( ServiceClient.ANON_OUT_IN_OP );
Options options = new Options();
options.setTransportInProtocol( Constants.TRANSPORT_HTTP );

serviceClient.setTargetEPR( targetEPR );

options.setProperty( Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE ); // Thise seems to do nothing
options.setProperty( HTTPConstants.AUTHENTICATE, null );
options.setProperty( Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET );

MessageContext messageContext = new MessageContext();
messageContext.setIsSOAP11Explicit( false );
messageContext.setDoingREST( true );
client.addMessageContext( messageContext );

client.execute(true);

To me, this means that the Axis2 servlet should protect itself earlier on by detecting the invalid/unsupported content-type in the GET message.

Let me know if you need other information.

Jason


> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Assigned: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Deepal Jayasinghe reassigned AXIS2-3007:
----------------------------------------

    Assignee: Keith Godwin Chapman

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Issue Comment Edited: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515460 ] 

Jason Kania edited comment on AXIS2-3007 at 7/25/07 5:41 PM:
-------------------------------------------------------------

As an addendum, I have attempted to set the formatter within the client to define an appropriate content-type for the server and have discovered that the XFormURLEncodedFormatter method getTargetAddress references static method URLTemplatingUtil.appendQueryParameters which assumes an Envelope and Body even in a GET method. It then busts when no Envelope is provided.

On the server side, in TransportUtils method creastSOAPMessage line 130, I also noticed that there are attempts to convert REST messages to the application/xml format when receiving REST messages which would again blow up for a RESTFUL request.


 was:
As an addendum, I have attempted to set the formatter within the client to define an appropriate content-type for the server and have discovered that the XFormURLEncodedFormatter method getTargetAddress references static method URLTemplatingUtil.appendQueryParameters which assumes an Envelope and Body even in a GET method. It then busts when no Envelope is provided.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Closed: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Kania closed AXIS2-3007.
------------------------------

    Resolution: Fixed

As of the latest nightly build of 2007/07/30, this issue seems to be resolved.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515620 ] 

Deepal Jayasinghe commented on AXIS2-3007:
------------------------------------------

Hi Keith,
Please go ahead , and make sure you do not break any existing stuff.

Thanks
Deepal

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Issue Comment Edited: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515460 ] 

Jason Kania edited comment on AXIS2-3007 at 7/25/07 5:42 PM:
-------------------------------------------------------------

As an addendum, I have attempted to set the formatter within the client to define an appropriate content-type for the server and have discovered that the XFormURLEncodedFormatter method getTargetAddress references static method URLTemplatingUtil.appendQueryParameters which assumes an Envelope and Body even in a GET method. It then busts when no Envelope is provided.

On the server side, in TransportUtils method creastSOAPMessage line 130, I also noticed that there are attempts to convert REST messages to the application/xml format when receiving REST messages which would again blow up for a RESTful GET request.


 was:
As an addendum, I have attempted to set the formatter within the client to define an appropriate content-type for the server and have discovered that the XFormURLEncodedFormatter method getTargetAddress references static method URLTemplatingUtil.appendQueryParameters which assumes an Envelope and Body even in a GET method. It then busts when no Envelope is provided.

On the server side, in TransportUtils method creastSOAPMessage line 130, I also noticed that there are attempts to convert REST messages to the application/xml format when receiving REST messages which would again blow up for a RESTFUL request.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Keith Godwin Chapman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515204 ] 

Keith Godwin Chapman commented on AXIS2-3007:
---------------------------------------------

Axis2 uses a pluggable builder concept here. There is a mapping in your axis2.xml which specifies the builder to use for a specific contentType. When you do a GET (obviously it does not have a method body hence the inputStream is null here) the content type would be application/x-www-form-urlencoded most often than not (Firefox sends null hence we do a check and set the appropriate content type). There is a mapping which says application/x-www-form-urlencoded will be processed by org.apache.axis2.builder.XFormURLEncodedBuilder. In your case whats happened is that it has tried to process it using ApplicationXMLBuilder (which is the one to be used when the content type is application/xml which had a body). 

Can you check your axis2.xml on this. You should be able to solve it there without using the workaround u've specified. I wonderwhether there was another problem somewhere else. Could u please verify this. If the problem persists please provide the steps to recreate the issue to gether with the builder mappings in your axis2.xml.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Keith Godwin Chapman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515510 ] 

Keith Godwin Chapman commented on AXIS2-3007:
---------------------------------------------

Hi jason,

I see the problem now. I'll give you a workaround for the moment but I agree that we need to fix something here.

The workaround is to get rid of the Constants.Configuration.ENABLE_REST property but instead set the following property.
options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,"application/x-www-form-urlencoded"); 

With the introduction of messageBuilders and messageFormatters into axis2 we depended on using the message_Type property to select the relevant builder and formatter. Now you don't have to specifically enable rest on the client code to get it working. You just have to set the relevant messageType (Which is more or less contentType, the naming here is because messageType is independent of transport used) and the HTTPMethod to use. 

I'll fix the code so that it will look at the HTTPMethod before defaulting to ApplicationXMLFormatter when rest is enabled. Thanks for pointing this out. You may try the nightly or even the 1.3 release to have this fix.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Kania updated AXIS2-3007:
-------------------------------


For the latest nightly as of 2007/07/30, this functionality seems to work correctly.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Kania updated AXIS2-3007:
-------------------------------


I am using axis in an embedded servlet and the configuration is coming from the default axis2.xml from within the kernel jar file with some programmatic overrides of settings in code.

This means that one of two problems is likely; I am modifying content type inadvertantly or the act of enabling REST is not sufficient to properly set the content type. From looking at the Axis code, I have not seen an explicit way to set the content type so having the wrong content type would be a side effect of something I am doing if enabling REST is working as expected. The content type is determined from other attributes and never explicitly set. Correct me if I am wrong.

I am also wondering if it might be caused by a content-type header being set in the GET method in which case this error should be caught beforehand, either lower in Axis2 or by the web server.

I will investigate further, but if there are some areas of code to look into for changes in content type, I would appreciate direction.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Keith Godwin Chapman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515720 ] 

Keith Godwin Chapman commented on AXIS2-3007:
---------------------------------------------

This is the scenario at the moment. If the Axis Engine receives a REST request and if it cannot find a relevant builder that matches the content-type it uses that builder. If it cannot find a builder it uses the default. ApplicationXMLBuilder iof the request is s POST or XformURLEncodedBuilder if the request was a GET. 

The fix is for both client and server side. Its almost impossible to detect incorrectly typed messages untill it gets to the builder. It's the builder who is aware as to how the message should look like. This is because the builders are pluggable. Anybody can write a custom builder and set its relavalt content-type to "foo". Its only the builder who knows how to build this message. So thats the first point that we can detect an error. Afterall this is not deep in axis. We detect the error before passing the message to the axis engine.

Its 

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Kania updated AXIS2-3007:
-------------------------------


I have investigated and two potential issues exist. The source of the incorrect content type is actually from the ServiceClient because within TransportUtils in method getMessageFormatter, it defaults content-type to application/xml when REST is enabled. I am not sure whether this default being set makes sense given your previous comments.

TransportUtils.getMessageFormatter(MessageContext) line: 249	
HTTPSender.populateCommonProperties(MessageContext, URL, HttpMethodBase, HttpClient, String) line: 254	
HTTPSender.sendViaGet(MessageContext, URL, String) line: 89	
HTTPSender.send(MessageContext, URL, String) line: 59	
CommonsHTTPTransportSender.writeMessageWithCommons(MessageContext, EndpointReference, OMOutputFormat) line: 305	
CommonsHTTPTransportSender.invoke(MessageContext) line: 201	
AxisEngine.send(MessageContext) line: 452	
OutInAxisOperationClient.send(MessageContext) line: 330	
OutInAxisOperationClient.execute(boolean) line: 294	
...

Subsequently, I followed the call stack on the servlet side up and the content-type was not changed. Thus, reproduction of the error should be as simple as setting up the client as follows:

ServiceClient serviceClient = new ServiceClient();
OperationClient client = serviceClient.createClient( ServiceClient.ANON_OUT_IN_OP );
Options options = new Options();
options.setTransportInProtocol( Constants.TRANSPORT_HTTP );

serviceClient.setTargetEPR( targetEPR );

options.setProperty( Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE ); // Thise seems to do nothing
options.setProperty( HTTPConstants.AUTHENTICATE, null );
options.setProperty( Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET );

MessageContext messageContext = new MessageContext();
messageContext.setIsSOAP11Explicit( false );
messageContext.setDoingREST( true );
client.addMessageContext( messageContext );

client.execute(true);

To me, this means that the Axis2 servlet should protect itself earlier on by detecting the invalid/unsupported content-type in the GET message.

Let me know if you need other information.

Jason


> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515705 ] 

Jason Kania commented on AXIS2-3007:
------------------------------------

Keith,
  
  Sorry if I am responding in an incorrect manner. I did not see how you  responded without leaving a visibile comment in the problem ticket.
  
  Thanks for the fix. I will test shortly since I can't change code right away.
  
  From your comments, I believe that you fixed only the client side. Does  this leave a vulnerability on the server side in that incorrectly typed  messages will get too deep into the stack before being detected? If the  detection point for the error is at the expected location, then no  worries since this won't affect my usage, but offhand, I thought that  that my message had arrived fairly deep into the stack before the stack  discovered that the message would not be able to be processed.
  
  Thanks again,
  
  Jason

"Keith Godwin Chapman (JIRA)" <ji...@apache.org> wrote:  
 [  https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515633  ] 

Keith Godwin Chapman commented on AXIS2-3007:
---------------------------------------------

fixed in revision 559737. Commited to both trunk and branch.  

Jason can you check the latest nightly.


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




> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Keith Godwin Chapman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Keith Godwin Chapman updated AXIS2-3007:
----------------------------------------

    Attachment: patch.txt

Attaching a patch wchih solves the problem. When isDoingREST is true check for the HTTP_METHOD property in the message context and default accordingly. Can be overridden by specifying a specific messageType though.

Deepal shall I commit this to the 1.3 branch too. I think it'll be good if this goes into the release.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>         Attachments: patch.txt
>
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Kania updated AXIS2-3007:
-------------------------------


As an addendum, I have attempted to set the formatter within the client to define an appropriate content-type for the server and have discovered that the XFormURLEncodedFormatter method getTargetAddress references static method URLTemplatingUtil.appendQueryParameters which assumes an Envelope and Body even in a GET method. It then busts when no Envelope is provided.

> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Issue Comment Edited: (AXIS2-3007) RESTful services invocation self induces Input Stream Closed error

Posted by "Jason Kania (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515450 ] 

Jason Kania edited comment on AXIS2-3007 at 7/25/07 4:35 PM:
-------------------------------------------------------------

I have investigated and two potential issues exist. The source of the incorrect content type is actually from the ServiceClient because within TransportUtils in method getMessageFormatter, it defaults content-type to application/xml when REST is enabled. I am not sure whether this default being set makes sense given your previous comments unless it takes into account HTTP method type GET versus POST.

TransportUtils.getMessageFormatter(MessageContext) line: 249	
HTTPSender.populateCommonProperties(MessageContext, URL, HttpMethodBase, HttpClient, String) line: 254	
HTTPSender.sendViaGet(MessageContext, URL, String) line: 89	
HTTPSender.send(MessageContext, URL, String) line: 59	
CommonsHTTPTransportSender.writeMessageWithCommons(MessageContext, EndpointReference, OMOutputFormat) line: 305	
CommonsHTTPTransportSender.invoke(MessageContext) line: 201	
AxisEngine.send(MessageContext) line: 452	
OutInAxisOperationClient.send(MessageContext) line: 330	
OutInAxisOperationClient.execute(boolean) line: 294	
...

Subsequently, I followed the call stack on the servlet side up and the content-type was not changed. Thus, reproduction of the error should be as simple as setting up the client as follows:

ServiceClient serviceClient = new ServiceClient();
OperationClient client = serviceClient.createClient( ServiceClient.ANON_OUT_IN_OP );
Options options = new Options();
options.setTransportInProtocol( Constants.TRANSPORT_HTTP );

serviceClient.setTargetEPR( targetEPR );

options.setProperty( Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE ); // Thise seems to do nothing
options.setProperty( HTTPConstants.AUTHENTICATE, null );
options.setProperty( Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET );

MessageContext messageContext = new MessageContext();
messageContext.setIsSOAP11Explicit( false );
messageContext.setDoingREST( true );
client.addMessageContext( messageContext );

client.execute(true);

To me, this means that the Axis2 servlet should protect itself earlier on by detecting the invalid/unsupported content-type in the GET message.

Let me know if you need other information.



 was:
I have investigated and two potential issues exist. The source of the incorrect content type is actually from the ServiceClient because within TransportUtils in method getMessageFormatter, it defaults content-type to application/xml when REST is enabled. I am not sure whether this default being set makes sense given your previous comments.

TransportUtils.getMessageFormatter(MessageContext) line: 249	
HTTPSender.populateCommonProperties(MessageContext, URL, HttpMethodBase, HttpClient, String) line: 254	
HTTPSender.sendViaGet(MessageContext, URL, String) line: 89	
HTTPSender.send(MessageContext, URL, String) line: 59	
CommonsHTTPTransportSender.writeMessageWithCommons(MessageContext, EndpointReference, OMOutputFormat) line: 305	
CommonsHTTPTransportSender.invoke(MessageContext) line: 201	
AxisEngine.send(MessageContext) line: 452	
OutInAxisOperationClient.send(MessageContext) line: 330	
OutInAxisOperationClient.execute(boolean) line: 294	
...

Subsequently, I followed the call stack on the servlet side up and the content-type was not changed. Thus, reproduction of the error should be as simple as setting up the client as follows:

ServiceClient serviceClient = new ServiceClient();
OperationClient client = serviceClient.createClient( ServiceClient.ANON_OUT_IN_OP );
Options options = new Options();
options.setTransportInProtocol( Constants.TRANSPORT_HTTP );

serviceClient.setTargetEPR( targetEPR );

options.setProperty( Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE ); // Thise seems to do nothing
options.setProperty( HTTPConstants.AUTHENTICATE, null );
options.setProperty( Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET );

MessageContext messageContext = new MessageContext();
messageContext.setIsSOAP11Explicit( false );
messageContext.setDoingREST( true );
client.addMessageContext( messageContext );

client.execute(true);

To me, this means that the Axis2 servlet should protect itself earlier on by detecting the invalid/unsupported content-type in the GET message.

Let me know if you need other information.


> RESTful services invocation self induces Input Stream Closed error
> ------------------------------------------------------------------
>
>                 Key: AXIS2-3007
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3007
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 2000, Eclipse IDE
>            Reporter: Jason Kania
>            Assignee: Keith Godwin Chapman
>
> When making REST GET calls to an API, Axis 2 core sets its input stream to null and then complains later that its stream has been closed. The following partial stack trace demonstrates the problem.
> ApplicationXMLBuilder.processDocument(InputStream, String, MessageContext) line: 49	
> TransportUtils.createSOAPMessage(MessageContext, InputStream, String) line: 130	
> RESTUtil.processURLRequest(MessageContext, OutputStream, String) line: 98	
> AxisServlet$ProcessRESTRequest.processURLRequest() line: 776	
> AxisServlet.doGet(HttpServletRequest, HttpServletResponse) line: 238	
> AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707	
> AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
> ServletHolder.handle(ServletRequest, ServletResponse) line: 487	
> ...
> In RESTUtil, method processURLRequest, the following call is made on line 98
>                 soapEnvelope = TransportUtils
>                         .createSOAPMessage(msgContext, null, contentType);
> where the null is supposed to be the input stream
> Thus, when line 49 of ApplicationXMLBuilder in method processDocument is encountered,
>             PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
> where inputStream is null,
> the exception "java.io.IOException: Stream closed" is generated once the empty stream is read at line 51
> of ApplicationXMLBuilder:
>            if ((b = pushbackInputStream.read()) > 0) {
> For straight Axis use, this issue is a blocker, but I have worked around the problem by filtering empty get methods at the servlet level and am populating them with content for now.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org