I'm using maven-jaxb2-plugin
to generate my models based on .wsdl
file. Now I need to add annotation to one of the classes. I tried to use jaxb2-basics-annotate
and was very close to succeed, but now I'm stuck.
My goal is to achieve this:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BinaryObjectType", propOrder = {
"value"
})
public class BinaryObjectType {
@XmlValue
@XmlJavaTypeAdapter(BinaryObjectTypeValueAdapter.class)
protected byte[] value;
}
but my current output is:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BinaryObjectType", propOrder = {
"value"
})
@XmlJavaTypeAdapter(BinaryObjectTypeValueAdapter.class)
public class BinaryObjectType {
@XmlValue
protected byte[] value;
}
My bunding.xjb
looks like this:
<jxb:bindings schemaLocation="file:./schema.wsdl"
node="//xs:complexType[@name='BinaryObjectType']/xs:simpleContent">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter"
value="example.mapper.BinaryObjectTypeValueAdapter">
</annox:annotate>
</annox:annotate>
</jxb:bindings>
Relevant fragment of the .wsdl
:
<xsd:complexType name="BinaryObjectType">
<xsd:annotation...>
<xsd:simpleContent>
<xsd:extension base="xsd:base64Binary">
<xsd:attribute name="format" type="xsd:normalizedString" use="optional">
...
</xsd:extension>
</xsd:simpleContent>
I cannot modify it. Basically my problem is that I don't know how to specify XPath to the value
property of BinaryObjectType
class. I tried to use simpleContent, extension etc., but nothing worked for me. I saw that I can specify target
on annox:annotate
level, but it didn't help.
All day googling and I found that JAXB bindings - address content of an xs:string extension with xpath. Not yet implemented, but looks like an answer.