【发布时间】:2015-02-17 07:09:49
【问题描述】:
当我在soap UI中使用以下请求时,一切正常:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:_0="http://types.kamal.com/5_0/">
<soapenv:Header/>
<soapenv:Body>
<_0:getNumberOfMatches>
<Id>XXX</Id>
<erPassword>XXX</erPassword>
<name>KOL</name>
<timing>
<start>XXXX</start>
</timing>
</_0:getNumberOfMatches>
</soapenv:Body>
</soapenv:Envelope>
如果我在根级别 <abc>1</abc> 传递一个元素,它仍然可以正常工作。请求变成了这样。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:_0="http://types.kamal.com/5_0/">
<soapenv:Header/>
<soapenv:Body>
<_0:getNumberOfMatches>
<Id>XXX</Id>
<erPassword>XXX</erPassword>
<name>KOL</name>
<timing>
<start>XXXX</start>
</timing>
<abc>1</abc>
</_0:getNumberOfMatches>
</soapenv:Body>
</soapenv:Envelope>
但是,如果我在计时元素下添加这个标签 <abc>1</abc>,它就会开始给我 Un-Marshaling 异常。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:_0="http://types.kamal.com/5_0/">
<soapenv:Header/>
<soapenv:Body>
<_0:getNumberOfMatches>
<Id>XXX</Id>
<erPassword>XXX</erPassword>
<name>KOL</name>
<timing>
<start>XXXX</start>
<abc>1</abc>
</timing>
</_0:getNumberOfMatches>
</soapenv:Body>
</soapenv:Envelope>
如果有人对 JAX-WS 使用的 Unmarshalling 机制有任何想法。 以及为什么它在父级工作并且在嵌套标签的情况下停止工作。
【问题讨论】:
-
你得到了什么异常?
-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Unmarshalling Error: unexpected element (uri:"", local:"abc"). Expected elements are &lt;{}start></faultstring> </soap:Fault> </soap:Body> </soap:Envelope>