I have the following generated enumeration type. The issue I have is that for some reason (presumably capitalisation) that an underscore is inserted in the NCBonus value.
I would like to know how I can prevent that from happening when generating the enumeration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="PromoType">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="MEM"/>
* <enumeration value="COU"/>
* <enumeration value="CHA"/>
* <enumeration value="SAD"/>
* <enumeration value="NCBonus"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "PromoType")
@XmlEnum
public enum PromoType {
MEM("MEM"),
COU("COU"),
CHA("CHA"),
SAD("SAD"),
@XmlEnumValue("NCBonus")
NC_BONUS("NCBonus");
I have tried using the global bindings option
<jxb:globalBindings underscoreBinding="asCharInWord" xmlns:xs="http://www.w3.org/2001/XMLSchema">
which has undesired consequences on other objects but makes no different to the enum type.
In addition I have tried using
<jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd" node="//xs:schema">
<jaxb:bindings node="xs:simpleType[@name='PromoType']">
<jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>
all to no avail.
Could someone please advise how I can achieve this goal please.
The answer that worked for me was to move the jaxb bindings out of the jaxws bindings file.
jaxb_bindings.xml
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd">
<jaxb:bindings node="//xsd:simpleType[@name='PromoType']">
<jaxb:typesafeEnumClass name="PromoType">
<jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>
</jaxb:typesafeEnumClass>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
wsdl_bindings.xml
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="../wsdl/insurance_service.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
pom.xml
<build> <plugins> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.codegen.version}</version> <executions> <execution> <id>csg</id> <phase>generate-sources</phase> <configuration> <wsdlOptions> <wsdlOption> <wsdl>${project.basedir}/src/main/resources/v2_3/wsdl/insurance_service.wsdl</wsdl> <extraargs> <extraarg>-xjc-verbose</extraarg> <extraarg>-verbose</extraarg> </extraargs> <bindingFiles> <bindingFile>${project.basedir}/src/main/resources/common_binding.xml</bindingFile> <bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/wsdl_binding.xml</bindingFile> <bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/jaxb_bindings.xml</bindingFile> </bindingFiles> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions>