我使用 xjc 从 XSD 创建 java 对象。
现在我正在尝试将 xml 文档解组为 java 对象,但我得到:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"GlobalComponentInformation
这里有吗?
编辑:
我正在传递一个 org.w3c.dom.Document 对象,它从 Web 服务调用(轴 Web 服务)返回...
注意,这里要解析的 ws 返回的 Document 对象包含以下根元素:
<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;