關於cxf WebService中錯誤信息的解決 javax.xml.bind.UnmarshalException

最近一直在做web Service的調試,發現在我本地系統 調用服務端那邊的doCommand方法老是報下面的錯誤,

 Caused by: javax.xml.bind.UnmarshalException: 意外的元素 (uri:"", local:"OContent")。所需元素爲<{}return>。

但是我又沒調用 Unmarshal 解析xml這個方法,我把自己的wsdl文件貼出來

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://hxgroup.cn" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://hxgroup.cn" name="MDMService">
<wsdl:types>
<xsd:schema targetNamespace="http://hxgroup.cn">
<xsd:element name="DoCommand">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FileFormat" type="xsd:string"/>
<xsd:element name="IsSync" type="xsd:string"/>
<xsd:element name="IContent" type="xsd:string"/>
<xsd:element name="ITimeout" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DoCommandResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="OContent" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

查了很多資料都沒找到解決方案,後來我把上面的wsdl文件中的OContent 改爲return,然後重新生成下代碼,居然好了。 不知道是啥原因,只是按報錯信息的字面意思去改。先寫到這,有進一步發現再說明

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章