Java SOAP响应反序列化中的问题
我有一个SOAP响应,我想将其反序列化为SOAPApplicationResult对象。我已经成功地从响应中获取了NS1和NS2类型,但在从响应中反序列化某些NS3类型时遇到了问题。 下面是我用来反序列化和SOAP响应的代码Java SOAP响应反序列化中的问题,java,web-services,soap,xml-parsing,axis,Java,Web Services,Soap,Xml Parsing,Axis,我有一个SOAP响应,我想将其反序列化为SOAPApplicationResult对象。我已经成功地从响应中获取了NS1和NS2类型,但在从响应中反序列化某些NS3类型时遇到了问题。 下面是我用来反序列化和SOAP响应的代码 String fileName = "com/servicebus/thirdparty/response.xml"; String response = SystemUtil.loadFileAsString(fileName); org.
String fileName = "com/servicebus/thirdparty/response.xml";
String response = SystemUtil.loadFileAsString(fileName);
org.apache.axis.server.AxisServer server = new org.apache.axis.server.AxisServer();
MessageContext msgContext = new MessageContext(server);
registerMessage(msgContext);
java.io.Reader reader = new java.io.StringReader(response);
DeserializationContext dser = new DeserializationContext(new org.xml.sax.InputSource(reader), msgContext,
Message.RESPONSE);
dser.parse();
SOAPEnvelope env = dser.getEnvelope();
RPCElement rpcElem = (RPCElement) env.getFirstBody();
MessageElement struct = rpcElem.getRealElement();
Iterator childElements = struct.getChildElements();
while (childElements.hasNext())
{
org.apache.axis.description.ParameterDesc param;
MessageElement next = (MessageElement) childElements.next();
SOAPApplicationResult objectValue = (SOAPApplicationResult) next.getValueAsType(new javax.xml.namespace.QName(
"SOAPApplicationResult","http://soap.xxxx.yyyy.com"), SOAPApplicationResult.class);
String serializeAxisObject = AxisObjectUtil.serializeAxisObject(objectValue, true, true);
}
当我从响应中删除OccupationLoading和PersonObjectList类型时,它将被反序列化,但这两种类型都不起作用。它给出了错误org.xml.sax.SAXException:com.webservices.thirdparty.generated.infexpert.SOAPPersonResult-PersonObjectList中的元素无效。我为NS2提供了QName new javax.xml.namespace.QNameSOAPApplicationResult。似乎我必须将多个QName映射到上下文,但不知道如何做
这是SOAP响应:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:NS1="urn:ABCDSoapProviderIntf-IABCDSOAPProvider">
<NS1:calculateResponse xmlns:NS2="http://soap.xxxx.yyyyy.com"
xmlns:NS3="http://soap.xxxx.zzzz.com/">
<return xsi:type="NS2:SOAPApplicationResult">
<ErrorMessage xsi:type="xsd:string" />
<Result xsi:type="xsd:string" />
<PersonResults xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:SOAPPersonResult[1]">
<item xsi:type="NS3:ABCDSoapPersonResult">
<ID xsi:type="xsd:string">1245245</ID>
<Result xsi:type="xsd:string">Doc</Result>
<RuleResults xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:SOAPRuleResult[1]">
<item xsi:type="NS2:SOAPRuleResult">
<Result xsi:type="xsd:string">Doc</Result>
<Notice xsi:type="xsd:string">A Document is required</Notice>
</item>
</RuleResults>
<ProductResults xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:SOAPProductResult[1]">
<item xsi:type="NS3:ABCDSOAPProductResult">
<Result xsi:type="xsd:string">Offer</Result>
<ID xsi:type="xsd:string">Some Id</ID>
<RuleResults xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:SOAPRuleResult[1]">
<item xsi:type="NS2:SOAPRuleResult">
<Result xsi:type="xsd:string">Offer</Result>
<Notice xsi:type="xsd:string">Standard</Notice>
<Reasons xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="NS2:SOAPReason[0]" />
</item>
</RuleResults>
<OccupationLoading xsi:type="NS3:SOAPPermanentLoading">
<BeginAfter xsi:type="xsd:int">0</BeginAfter>
<BeginEnd xsi:type="xsd:int">0</BeginEnd>
</OccupationLoading>
</item>
</ProductResults>
<PersonObjectList xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]">
<item>Z001</item>
<item>E6679</item>
</PersonObjectList>
</item>
</PersonResults>
</return>
</NS1:calculateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>