gpt4 book ai didi

java - Apache Axis 响应无类型

转载 作者:太空宇宙 更新时间:2023-11-04 08:24:33 25 4
gpt4 key购买 nike

我有一个使用 axis 的 Web 服务客户端。它使用文档/文字样式,并且应该具有无效响应,但是服务器坚持在肥皂体内发送 header 响应,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Code>
<SOAP-ENV:Value>HTTP/1.1 200 OK</SOAP-ENV:Value>
</SOAP-ENV:Code>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

当然,客户端正在引发反序列化器异常,如下所示

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)

有没有办法绕过这个异常,而不是使用invokeOneWay函数(我认为这不是一个好方法)?

最佳答案

通过向服务添加输出消息解决了这个问题。

<xsd:element name="Code" type="codeDT" />
<xsd:complexType name="codeDT">
<xsd:sequence>
<xsd:any />
</xsd:sequence>
</xsd:complexType>
...
<wsdl:message name="Code">
<wsdl:documentation />
<wsdl:part name="Code" element="p1:Code" />
</wsdl:message>

只需将 stub 内的返回类型 AXIS_VOID 更改为 SOAP_ELEMENT 就可以正常工作,但是哦,好吧;这样我就可以获取值标签内的内容,即使我不需要它。

关于java - Apache Axis 响应无类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8874784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com