开发者

How do I handle HTTP error codes in an Axis 1 client

We're running an Axis 1 Java client. The web service will sometime return an HTTP error code 500 along with some meaningless HTML body content. In such cases, we get a

javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPE开发者_运维百科nvelope(Message.java:435)
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) 

I'm certain there's an easy way to catch HTTP errors such that no class attempts to read the SOAP envelope, but I haven't been able to find the right terms to google.

How do I configure Axis (client-config.wsdd) or which handlers do I need to implement so that a webservice reply with an HTTP error code >= 400 can be properly handled?

Thanks Simon


The cause is in Axis itself.

org.apache.axis.transport.http.HTTPSender#readFromSocket()

will log (level debug)

log.debug(outMsg.getSOAPEnvelope().toString());

If there is no valid SOAP envelope, that call causes the stacktrace above.

Simon

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜