没有类型的Apache Axis响应
问题描述:
我有一个使用轴的Web服务客户端。它使用文档/文字风格,应该有无效响应但是在服务器上发送头响应SOAP体的内部如下没有类型的Apache 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函数(这不是我想的好办法)?
答
通过将输出消息添加到服务来解决它。
<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内存根工作正常,但哦;这样,即使我不需要它,我也可以获得价值标签内的内容。