While generating java classes from WSDL using wsimport Enum names are getting changed:
pom.xml
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<wsdlLocation>http://localhost/service/*</wsdlLocation>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<xdebug>true</xdebug>
<verbose>true</verbose>
<target>2.0</target>
<keep>true</keep>
</configuration>
<executions>
<execution>
<id>PaymentCheck</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.pay.jaxws.paymentCheck</packageName>
<wsdlDirectory>${basedir}/src/main/resources/wsdl/internal</wsdlDirectory>
<wsdlFiles>
<wsdlFile>PaymentCheck.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
WSDL Enum described as:
<schema> ....
<simpleType name="subFailureType">
<restriction base="string">
<enumeration value="SUCCESS"/>
<enumeration value="FA01" /> <!-- Failure code for - Not enough cover -->
<enumeration value="FA01" /> <!-- Failure code for - All other cases -->
</restriction>
</simpleType>
</schema>
Generated Class:
@XmlType(name = "subFailureType")
@XmlEnum
public enum SubFailureType {
SUCCESS("SUCCESS"),
@XmlEnumValue("FA01")
FA_01("FA01"),
@XmlEnumValue("FA02")
FA_02("FA02");
private final String value;
SubFailureType(String v) {
value = v;
}
public String value() {
return value;
}
public static SubFailureType fromValue(String v) {
for (SubFailureType c: SubFailureType.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
instead of Enum FA01/FA02 additional underscore "FA_01" is coming in the name.
Is there any way to correct this ? It's similar to the question wsimport generating enum types incorrectly with extra underscore asked in 2012, not finding any workaround or solution to this.
Able to solve this issue using Bindings, In pom.xml added binding entry:
<configuration>
<packageName>com.pay.jaxws.paymentCheck</packageName>
<wsdlDirectory>${basedir}/src/main/resources/wsdl/internal</wsdlDirectory>
<wsdlFiles>
<wsdlFile>PaymentCheck.wsdl</wsdlFile>
</wsdlFiles>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/wsdl/internal/paymentCheckBindings.xjb</bindingFile>
</bindingFiles>
</configuration>
and added paymentCheckBinding.xjb as below
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings
wsdlLocation="PaymentCheck.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://account.ws.integration.payment.te.com/PaymentCheckWS']">
<jaxb:bindings
node="//xs:simpleType[@name='subFailureType']/xs:restriction/xs:enumeration[@value='FA01']">
<jaxb:typesafeEnumMember name="FA01" />
</jaxb:bindings>
</jaxws:bindings>
</jaxws:bindings>