java - XJC - ignore nillable=true -
in order avoid values being wrapped in jaxbelement
, generating classes xsd following bindings file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" version="2.1"> <jaxb:globalbindings generateelementproperty="false"> <xjc:simple /> </jaxb:globalbindings> </jaxb:bindings>
however, there problem nillable
fields. following xsd:
<!-- ... --> <xsd:complextype name="getshortcustomerin"> <xsd:sequence> <xsd:element name="fieldone" nillable="true" type="xsd:string"/> <xsd:element name="fieldtwo" type="xsd:string" minoccurs="0"/> </xsd:sequence> </xsd:complextype> <!-- ... -->
xjc generate class fields:
@xmlelement(required = true, nillable = true) protected string fieldone; @xmlelement(nillable = true) protected string fieldtwo;
when fieldtwo
null
request contain field nil set true:
<fieldone>1001714</fieldone> <fieldtwo xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nil="true"/>
this problem webservice integrate since chokes on such request, despite fact valid xml. have been said when field null
should not present in request @ all. realize in order meet requirement, generated classes cannot have @xmlelement
annotation's nillable
attribute set true
.
is there way ignore nillable=true
in xsd files when generating classes xjc?
Comments
Post a Comment