我已经使用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