这是java jaxb解组代码:
private void fillProcessCreditApplication() {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ProcessCreditApplication.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
ProcessCreditApplication processCreditApplication = (ProcessCreditApplication) jaxbUnmarshaller.unmarshal(xml);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
这里是例外:
javax.xml.bind.UnmarshalException:意外元素(uri:“”,本地:“ ProcessCreditApplication”)。预期的元素是<{{http://www.starstandards.org/STAR} processCreditApplication>,<{http://www.starstandards.org/STAR} processCreditApplicationDataArea>
那是什么意思? 这是xjc生成的ProcessCreditApplication Java代码:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ProcessCreditApplication", propOrder = {
"applicationArea",
"dataArea"
})
public class ProcessCreditApplication {
@XmlElement(name = "ApplicationArea", required = true)
protected ApplicationArea applicationArea;
@XmlElement(name = "DataArea", required = true)
protected ProcessCreditApplicationDataArea dataArea;
...
ApplicationArea.java和ProcessCreditApplicationData.java与ProcessCreditApplication.java位于同一文件夹中。
这是传入的xml:
<?xml version="1.0" encoding="utf-8"?>
<ProcessCreditApplication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ApplicationArea>
<Sender>
...
编辑:这是package-info.java代码:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.starstandards.org/STAR", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.starstandards.star;
编辑:这是生成的ProcessCreditApplicationDataArea类的代码:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ProcessCreditApplicationDataArea", propOrder = {
"process",
"creditApplication"
})
public class ProcessCreditApplicationDataArea {
建议?