伙计们!我正在尝试获取SOAPBody对象请求的字符串。我正在使用axis 2和Tomcat 9进行Web服务。
public static String getXMLSoapBody()
{
log.getLogger().debug("TEST - getXmlSoapBody - START");
String soapBody;
SOAPBody body;
MessageContext messageContext = MessageContext.getCurrentMessageContext();
try {
SOAPEnvelope env = messageContext.getEnvelope();
body = env.getBody();
}
catch(Exception e)
{
log.getLogger().error("SOAP Exception :" + e.toString());
e.printStackTrace();
return null;
}
soapBody = body.toString();
return soapBody;
但当我发送请求时,我收到此错误:catalina.out:10:41:26.935 [http-nio-8080-exec-2]错误org.apache.axis2.transport.http.AxisServlet - processAxisFault()从MessageContext示例中发现一个空HTTP状态,将HttpServlet响应状态设置为:axis2.http.response.state
我的日志文件:2022年12月1日10:41:26 [http-nio-8080-exec-2](TransUtils.java:287)调试测试-获取XmlSoapBody-开始
我试图查看它的完整堆栈跟踪,但是当我尝试使用try/catch来获取soapBody = body.toString();行我收到此错误,但前一个错误不是:
org.apache.axiom.om.NodeUnavailableException
at org.apache.axiom.om.impl.common.AxiomExceptionTranslator.translate(AxiomExceptionTranslator.java:35)
at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown Source)
at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serializeAndSurfaceIOException(Unknown Source)
at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown Source)
at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown Source)
at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown Source)
at org.apache.axiom.om.impl.llom.AxiomElementImpl.toString(Unknown Source)
at uk.co.celesio.orders.server.TransUtils.getXMLSoapBody(TransUtils.java:304)
我的要求:
<?xml version='1.0' encoding='windows-1252'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<MyTestRequest xmlns="...">
...
</MyTestRequest>
</soapenv:Body>
</soapenv:Envelope>
尝试使用try/catch查看完整错误,还尝试记录此错误,但在这两种情况下,我都收到NodeUnavailableException
1条答案
按热度按时间w8ntj3qf1#
NodeUnavailableException
表示SOAP消息的正文已经被使用,很可能是被一个数据绑定使用,该数据绑定将SOAP消息转换为Java对象(不幸的是,您只显示了堆栈跟踪的一部分,因此无法从提供的信息中看出这一点)。关于此问题的正确解决方案:这取决于您实际尝试实现的目标(这可能是XY problem)。