我已經使用xjc從XSD創建Java對象。unmarshalling xml文檔到Java對象(jaxb)問題
,現在我試圖將XML文檔解組到Java對象,但我得到:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"GlobalComponentInformation
任何這裏嗎?
編輯:
我傳遞一個org.w3c.dom.Document中的對象,它從一個Web服務調用(Axis Web服務)返回......
注意,Document對象從WS返回這裏要分析的包含以下根元素:
<GlobalInformationResponseDocument xmlns="" />
@XmlRootElement類的樣子:
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"wsExternalResponse"
})
@XmlRootElement(name = "GlobalInformationResponseDocument")
public class GlobalInformationResponseDocument {
@XmlElement(name = "WS_ExternalResponse", required = true)
protected WSExternalResponseType wsExternalResponse;
/**
* Gets the value of the wsExternalResponse property.
*
* @return
* possible object is
* {@link WSExternalResponseType }
*
*/
public WSExternalResponseType getWSExternalResponse() {
return wsExternalResponse;
}
/**
* Sets the value of the wsExternalResponse property.
*
* @param value
* allowed object is
* {@link WSExternalResponseType }
*
*/
public void setWSExternalResponse(WSExternalResponseType value) {
this.wsExternalResponse = value;
}
}
包信息:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.mycompany.com/GlobalInformationResponseExt",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.company.jaxb.client;
你的根類的@XmlRootElement是什麼樣的?另外你的包信息類是什麼樣的(如果你有)?還有什麼樣的XML輸入是你解組(流,DOM等)? – 2010-11-08 03:57:04
GlobalComponentInformation在哪裏進來?它可能是在你分析的XML響應中返回的?你沒有在XSD中定義它嗎? – Kissaki 2010-11-08 10:56:10