unmarshall jaxb RegistryObjectListType null content

Я пытаюсь разобрать все, что называется adhocqueryresponse.

Этот объект имеет атрибут RegistryObjectListType, внутри которого есть что-то странное:

List<JAXBElement<? extends IdentifiableType>> identifiable

когда я марширую этот объект, у меня нет проблем, но в немаршалле идентифицируемый атрибут всегда равен нулю.

у меня нет решения мой код unmarshall:

    JAXBContext jaxbContext = JAXBContext.newInstance(
            "oasis.names.tc.ebxml_regrep.xsd.lcm._3:"
            + "oasis.names.tc.ebxml_regrep.xsd.query._3:"
            + "oasis.names.tc.ebxml_regrep.xsd.rim._3:"
            + "oasis.names.tc.ebxml_regrep.xsd.rs._3"
    );

    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    StringReader reader = new StringReader(xml);
    Object object = unmarshaller.unmarshal(reader);
    response = (AdhocQueryResponse) object;

и ответ adhoquery:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "registryObjectList"
})
@XmlRootElement(name = "AdhocQueryResponse", namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")
public class AdhocQueryResponse
    extends RegistryResponseType
{

    @XmlElement(name = "RegistryObjectList", namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", required = true)
    protected RegistryObjectListType registryObjectList;

и RegistryObjectListType:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RegistryObjectListType", propOrder = {
    "identifiable"
})

public class RegistryObjectListType {
    @XmlElementRef(name = "Identifiable", namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", type = JAXBElement.class)
    protected List<JAXBElement<? extends IdentifiableType>> identifiable;

Я хочу, чтобы JAXBElement, который расширяет Identifiable, был:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExtrinsicObjectType", propOrder = {
    "contentVersionInfo"
})
public class ExtrinsicObjectType
    extends RegistryObjectType
{

    @XmlElement(name = "ContentVersionInfo")
    protected VersionInfoType contentVersionInfo;
    @XmlAttribute(name = "mimeType")
    protected String mimeType;
    @XmlAttribute(name = "isOpaque")
    protected Boolean isOpaque;

наконец, мой XML для unmarshall:

<AdhocQueryResponse xmlns:ns2="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" xmlns="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
    <RegistryObjectList>
        <ExtrinsicObject mimeType="text/xml" status="urn:oasis:names:tc:ebxmlregrep:StatusType:Approved" objectType="urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1" lid="ola" home="" id="identificador de la instancia" xmlns="" xmlns:ns3="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
            <ns3:Slot name="creationTime">
                <ns3:ValueList>
                    <ns3:Value>aaaaMMddhhmmss</ns3:Value>
                </ns3:ValueList>
            </ns3:Slot>
        </ExtrinsicObject>
    </RegistryObjectList>
</AdhocQueryResponse>

объект фабрики:

@XmlElementDecl(namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", name = "ExtrinsicObject", substitutionHeadNamespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", substitutionHeadName = "Identifiable")
public JAXBElement<ExtrinsicObjectType> createExtrinsicObject(ExtrinsicObjectType value) {
    return new JAXBElement<ExtrinsicObjectType>(_ExtrinsicObject_QNAME, ExtrinsicObjectType.class, null, value);
    }

У меня есть подсказка, если я добавлю:

  @XmlAnyElement(lax=false)
    @XmlElementRefs({
    @XmlElementRef(name = "ExtrinsicObject", namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", type = JAXBElement.class),
    @XmlElementRef(name = "Identifiable", namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", type = JAXBElement.class)
   } )   

в атрибуте, определяемом классом RegistryObjectListType, unmarshall не является нулевым, но имеет тип: ElementNSImpl, а не JaxbElement

Маршалл работает отлично, любая помощь приветствуется

0 ответов

Другие вопросы по тегам