[ https://issues.apache.org/jira/browse/AXIS2-6091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17941984#comment-17941984 ]
Jeff Thomas commented on AXIS2-6091: ------------------------------------ Created [https://github.com/apache/axis-axis2-java-core/pull/902] Made some "improvements" to above code suggestions. > Problem handling HTTP Response in OutInAxisOperationClient / TransportUtils > --------------------------------------------------------------------------- > > Key: AXIS2-6091 > URL: https://issues.apache.org/jira/browse/AXIS2-6091 > Project: Axis2 > Issue Type: Bug > Components: kernel > Affects Versions: 2.0.0 > Reporter: Jeff Thomas > Priority: Major > > I am testing upgrading to Axis2 2.0.0 (and associated Axiom 2.0.0 upgrade). > I am seeing a processing error when a HTTP 404 is received by an > OutInAxisOperationClient when an endpoint is not available (target > application not running) but the Tomcat instance is running. > The returned response obtained from the input-stream is: > > {code:java} > <!doctype html> > <html lang="en"> > <head> > <title>HTTP Status 404 – Not Found</title> > <style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} > h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 > {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} > .line {height:1px;background-color:#525D76;border:none;}</style> > </head> > <body> > <h1>HTTP Status 404 – Not Found</h1> > <hr class="line"/> > <p> > <b>Type</b> Status Report</p> > <p> > <b>Description</b> The origin server did not find a current > representation for the target resource or is not willing to disclose that one > exists.</p> > <hr class="line"/> > <h3>Apache Tomcat/11.0.5</h3> > </body> > </html> {code} > The stacktrace for the fault is as follows: > > > {code:java} > org.apache.axis2.AxisFault: org.apache.axiom.core.stream.StreamException: > com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'd' (code > 100) after '<!' (malformed comment?) > at [row,col {unknown-source}]: [1,3] > at org.apache.axis2.AxisFault.makeFault(AxisFault.java:431) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > at > org.apache.axis2.kernel.TransportUtils.createSOAPMessage(TransportUtils.java:116) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > at > org.apache.axis2.kernel.TransportUtils.createSOAPMessage(TransportUtils.java:68) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > at > org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:347) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > {code} > Ultimately it lands in this chain: > > * OutInAxisOperationClient#processResponse -> > * TransportUtils#createSoapMessage -> > * ... > * TransportUtils#createDefaultDocumentElement > It lands here because it cannot find any configured MessageBuilder for the > content-type "text/html". > Here it comes in this code: > > {code:java} > private static OMElement createDefaultDocumentElement(MessageContext > msgContext, > InputStream inStream, > String type) { > OMElement documentElement; > if (msgContext.isDoingREST()) { > if (log.isDebugEnabled()) { > log.debug("Could not find a Builder for type (" + type + "). > Using REST."); > } > OMXMLParserWrapper builder = BuilderUtil.createPOXBuilder(inStream, > null); > documentElement = builder.getDocumentElement(); > } else { > // FIXME making soap defualt for the moment..might effect the > // performance > if (log.isDebugEnabled()) { > log.debug("Could not find a Builder for type (" + type + "). > Using SOAP."); > } > String charSetEnc = (String) msgContext > .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); > SOAPModelBuilder builder = > BuilderUtil.createSOAPModelBuilder(inStream, charSetEnc); > documentElement = builder.getDocumentElement(); > } > return documentElement; > } {code} > > The '{{{}isDoingRest{}}}' returns _false_ and the {{contentType}} is > 'text/html' and encoding 'UTF-8'. > The exception is thrown trying to parse the HTML to SOAP: > {code:java} > documentElement = builder.getDocumentElement(); {code} > Possibly this is also related to the code in {{HTTPSender#send}} for handling > 404/500 HTTP responses? > > > {code:java} > else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR > || statusCode == HttpStatus.SC_BAD_REQUEST || > statusCode == HttpStatus.SC_NOT_FOUND) { > processResponse = true; > fault = true; > }{code} > We would really like to get off our custom forks of Axis2/Axiom/Rampart - or > at least as close to the current release as possible but this is currently a > blocker for us. Our monitoring continuously polls endpoints that may or may > not be available and this generates loads of errors / stacktraces in our logs. > > I enabled the following parameter as a test to use the "UnknownBuilder" > > {code:java} > <parameter name="useDefaultFallbackBuilder">true</parameter> {code} > I didn't get the Axiom exception, but it only leads to a follow-up exception: > > > {code:java} > java.lang.IllegalArgumentException: The MessageContext does not have an > associated SOAPFault. > at > org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:533) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > at > org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:368) > ~[axis2-kernel-2.0.0.2-PWC.jar:2.0.0.2-PWC] > {code} > So all in all, if I am not analyzing this incorrectly, Axis2 doesn't seem to > be handling the case where an endpoint returns a 404/500 response that is > HTML and not SOAP (and probably other HTTP status as well (400 BAD_REQUEST, > 401 UNAUTHORIZED, 403 FORBIDDEN, 418 (I am a teapot! :P), ...). > > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@axis.apache.org For additional commands, e-mail: java-dev-h...@axis.apache.org