Search code examples
javajax-wswsimport

wsimport generating enum types incorrectly with extra underscore


I am using wsimport to generate my JAX-WS client from a WSDL file (which is also generated), and am having a problem where it is generating an enumeration on the client side that does not match the server side.

The applicable snippet from my WSDL file shows the correct entries:

<xs:simpleType name="type">
  <xs:restriction base="xs:string">
    <xs:enumeration value="BLAH_99X"/>
    <xs:enumeration value="BLAH_123"/>
    <xs:enumeration value="BLAH_ABC"/>
  </xs:restriction>
</xs:simpleType>

The applicable portion of the generated enum for the client is:

@XmlType(name = "type")
@XmlEnum
public enum Type {
    @XmlEnumValue("BLAH_99X")
    BLAH_99_X("BLAH_99X"),
    BLAH_123("BLAH_123"),
    BLAH_ABC("BLAH_ABC");
}

I would have expected that the enum items generated for the client would match the ones from the server side (and in the WSDL). However when you look it generates them all correctly other than the first item which generates as BLAH_99_X and then is mapped to the correct value.

Is there any real reason it has to generated that item the way it did? Has anyone else run into this and how to make it generate correctly?

Update

I added a crazy value (T1A32BCS12) to my enumeration just on a hunch, and it generated T_1_A_32_BCS_12("T1A32BCS12") as my enum item in the client code. So, it seems that anytime you have a letter and a number side-by-side wsimport is inserting an underscore between them. Is this a bug in wsimport? It seems that there isn't a logical reason this should happen.


Solution

  • In the interest of keeping things clean and not having pointless open questions around... this apparently is actually a bug in JAX-WS RI 2.2.7. As far as I have found there is no workaround to it.