We are trying to integrate with the service published in https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/taiif/wsdl/ixgd/DpiNtnlDeclaration_v1.0.wsdl
We have configured our gradle-based springboot application using the plugin 'com.github.bjornvester.wsdl2java'
When the tools generates the classes for the AddresType from
<xsd:complexType name="Address_Type">
<xsd:sequence>
<xsd:element name="CountryCode">
<xsd:annotation>
<xsd:documentation>This data element provides the country code associated with the entity’s (or person’s) address.</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="iso:CountryCode_Type">
<xsd:minLength value="1"/>
<xsd:maxLength value="2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:choice>
<xsd:element name="AddressFree" type="stf:StringMin1Max4000_Type">
</xsd:element>
<xsd:sequence>
<xsd:element name="AddressFix" type="dpi:AddressFix_Type"/>
<xsd:element name="AddressFree" type="stf:StringMin1Max4000_Type" minOccurs="0">
</xsd:element>
</xsd:sequence>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="legalAddressType" type="stf:OECDLegalAddressType_EnumType" use="optional">
</xsd:attribute>
</xsd:complexType>
the output is:
...
@XmlElementRefs({
@XmlElementRef(name = "CountryCode", namespace = "urn:oecd:ties:dpi:v1", type = JAXBElement.class, required = false),
@XmlElementRef(name = "AddressFree", namespace = "urn:oecd:ties:dpi:v1", type = JAXBElement.class, required = false),
@XmlElementRef(name = "AddressFix", namespace = "urn:oecd:ties:dpi:v1", type = JAXBElement.class, required = false)
})
protected List<JAXBElement<?>> content;
...
And when we try to do the java to xml, the application raises an exception saying:
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `jakarta.xml.bind.JAXBElement` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
Is there a way to solve it?
We have tried with xjb bindings, trying to rename a property or setting our own implementation, but looks like the xpath (it is a wsdl, that imports an xsd that also imports another xsd) is not being picked up.
We are expecting a class that offers a list in the way of getCountryCodeOrAddressFreeOrAddressFix()
Edit:
Ok, we found out that there were also methods on the objectFactory to create the different elements that are part of the 'content' list. And we ended up using them.
Ok, so we ended up using a bindings.xjb and replace the generated class with one of our own.
and in the build.gradle
We did try using the simplify plugin suggested by Laurent, but we were getting errors like "compiler was unable to honor this simplify:as-element-property customization"