Apache Axis 响应无类型

发布于 2024-12-27 07:20:39 字数 1728 浏览 0 评论 0原文

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

<?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 函数(我认为这不是一个好方法)?

I have a web service client using axis. It's using document/literal style and supposed to have void response however the server insists on sending header response inside of soap body as following

<?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>

And of course client is raising deserializer exception as following

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)

Is there a way to bypass this exception instead of using invokeOneWay function (which is not a good way I suppose)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2025-01-03 07:20:39

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

<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>

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

Solved it by adding output messages to service.

<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>

Just changing return type AXIS_VOID to SOAP_ELEMENT inside stub works fine but oh well; this way I can get what's inside of value tag even though I don't need it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文