http://xmlgw.companieshouse.gov.uk/의 응답을 비 정렬 화하고 있습니다. 이것은 마샬로 전송되는 텍스트입니다 :JAXB - 비 정렬 화 필드가 null입니다.
<NameSearch xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/NameSearch.xsd">
<ContinuationKey>...</ContinuationKey>
<RegressionKey>...</RegressionKey>
<SearchRows>20</SearchRows>
<CoSearchItem>
<CompanyName>COMPANY NAME</CompanyName>
<CompanyNumber>23546457</CompanyNumber>
<DataSet>LIVE</DataSet>
<CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
<CompanyDate></CompanyDate>
</CoSearchItem>
// more CoSearchItem elements
</NameSearch>
CoSearchItem의 모델은 다음과 같이이다 :
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NameSearch", namespace = "http://xmlgw.companieshouse.gov.uk/v1-0/schema", propOrder = {
"continuationKey",
"regressionKey",
"searchRows",
"coSearchItem"
})
@XmlRootElement(name = "NameSearch", namespace = "http://xmlgw.companieshouse.gov.uk/v1-0/schema")
public class NameSearch {
@XmlElement(name = "ContinuationKey", required = true)
protected String continuationKey;
@XmlElement(name = "RegressionKey", required = true)
protected String regressionKey;
@XmlElement(name = "SearchRows", required = true)
protected BigInteger searchRows;
@XmlElement(name = "CoSearchItem")
protected List<CoSearchItem> coSearchItem;
// setters and getters
}
패키지는이 주석이 있습니다 NameSearch 모델은이 구조를 가지고
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CoSearchItem", propOrder = {
"companyName",
"companyNumber",
"dataSet",
"companyIndexStatus",
"companyDate",
"searchMatch"
})
public class CoSearchItem {
@XmlElement(name = "CompanyName", required = true)
protected String companyName;
@XmlElement(name = "CompanyNumber", required = true)
protected String companyNumber;
@XmlElement(name = "DataSet", required = true)
protected String dataSet;
@XmlElement(name = "CompanyIndexStatus")
protected String companyIndexStatus;
@XmlElement(name = "CompanyDate")
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar companyDate;
@XmlElement(name = "SearchMatch")
protected String searchMatch;
// getters and setters
}
:
@XmlSchema(namespace = "http://xmlgw.companieshouse.gov.uk/v1-0", elementFormDefault = XmlNsForm.QUALIFIED, //
xmlns = {
@XmlNs(prefix = "xsi", namespaceURI = "http://www.w3.org/2001/XMLSchema-instance")
}
)
package uk.gov.companieshouse;
비 정렬 화는 Document
의 첫 번째 Node
에서 시작하여 any
항목 목록 안에 있습니다. 그러나 우리는 XML을 구문 분석 할 때 CoSearchItem의 모든 필드가 null로 설정되고 이유를 파악할 수 없습니다.
[this] (http://stackoverflow.com/questions/12747484/jaxb-parses-xml-child-into-null-only-the-attributes-are-set-in-the-object) help? – TheWhiteRabbit
Blaise처럼 @XmlSchema를 가리 킵니다. 잘못된 네임 스페이스 자격을 실현 한 후에 문제를 발견했습니다. – pablisco