I love Enum
for the type safety and also it makes code much more readable. I always make use of Enum
whenever I get the chance.
Problem started when I need to expose these codes as web services. For example, if I have an enum like this:
public enum Language {
ENGLISH(1),
BAHASA_MALAYSIA(2);
}
It will be exposed in wsdl as this:
<xs:simpleType name="language">
<xs:restriction base="xs:string">
<xs:enumeration value="ENGLISH"/>
<xs:enumeration value="BAHASA_MALAYSIA"/>
</xs:restriction>
</xs:simpleType>
If in the future if I decided to add a new language I will be in trouble, the wsdl file will be different and it will break older clients.
My question, how do I prevent the enum be exposed as enum in wsdl? I want it be exposed as simple datatype either String
or int
.
I am using JBoss WS if that matter.