如何处理 Axis 1 客户端中的 HTTP 错误代码
我们正在运行 Axis 1 Java 客户端。 Web 服务有时会返回 HTTP 错误代码 500 以及一些无意义的 HTML 正文内容。在这种情况下,我们会得到“
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.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
我确信有一种简单的方法可以捕获 HTTP 错误,这样就没有类尝试读取 SOAP 信封”,但我无法通过 google 找到正确的术语。
如何配置 Axis (client-config.wsdd) 或需要实现哪些处理程序才能正确处理 HTTP 错误代码 >= 400 的 Web 服务回复?
谢谢 西蒙
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.getSOAPEnvelope(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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因在于轴本身。
将记录(级别调试)
如果没有有效的 SOAP 信封,该调用将导致上面的堆栈跟踪。
西蒙
The cause is in Axis itself.
will log (level debug)
If there is no valid SOAP envelope, that call causes the stacktrace above.
Simon