I am pretty new to custom binding in Apache CXF or similar. I'm generating this in my Java Maven project using cxf-codegen-plugin. My XSD schema for classes are contained within a WSDL as shown below.
The classes get generated, etc all fine except for enum values. They only show as String values. I researched, and found that I need to create a custom binding.xml document. I included it in the pom.xml in the apache cxf plugin.
My custom binding file looks as follows:
<jxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
<jxb:bindings wsdlLocation="../wsdl/mywsdl.wsdl">
<jxb:bindings node="//xsd:element[@name='myEnum']">
<jxb:typesafeEnumClass name="MyEnum" />
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
The wsdl looks like this:
<WL5G3N0:definitions ...>
<WL5G3N0:types>
<xsd:schema ...>
<xsd:element name="myClass">
<xsd:element name="myEnum">
<xsd:simpleType>
<xsd:restriction base="xs:string">
<xsd:enumeration value="EnumVal1"/>
<xsd:enumeration value="EnumVal2"/>
<xsd:enumeration value="EnumVal3"/>
<xsd:enumeration value="EnumVal4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
....
I get the error: Thrown by JAXB : XPath evaluation of "//xsd:element[@name='myEnum']" results in empty target node at line 4 column 55 of schema file ... bindings.xml
I used an online xpath expression evaluator, and it seems to find the element named "myEnum". What else would I be missing here?
EDIT: the line
< jxb:bindings wsdlLocation="../wsdl/mywsdl.wsdl">
may be wrong since I can change the wsdl filename to something else (knowing it's the wrong filename) and I still get the same error. So how to link the file correctly?