I use CXF and wsdl2java to automatically create webservice classes.
Problem: somehow the web service I want to connect to has duplicate names for some elements:
Two declarations cause a collision in the ObjectFactory class
xsd looks like this:
<xs:schema targetNamespace="http://thenamespace"> <xs:complexType name="ViolatingName"> ... </xs:complexType> <xs:element name="ViolatingName" nillable="true" type="tns:ViolatingName"/> </xs:schema>
Xsd itself is imported inside wsdl, which is used to auto-generate jaxb classes as follows:
<wsdl:types> <xsd:schema targetNamespace="http://imports"> <xsd:import schemaLocation="https://path.to.xsd" namespace="http://thenamespace" />
I am trying to cover this with jaxb-bindings.xml :
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1"> <jaxb:bindings schemalocation="https://path.to.xsd" node="//xs:schema"> <jaxb:bindings node=".//xs:element[@name='ViolatingName']"> <jaxb:property name="ViolatingNameBinding" /> </jaxb:bindings> </jaxb:bindings> </jaxb:bindings>
Result:
[ERROR] XPath evaluation of "//xs:schema" results in empty target node (org.apache.cxf:cxf-codegen-plugin:3.0.1:wsdl2java:generate-sources:generate-sources)
Why is the wrong node here? Xsd has an xs:schema tag, so why doesn't it succeed?
Interesting fact: when I use any xpath tool, download the XSD to my local machine, check the path, then //xs:schema/xs:element[@name='ViolatingName'] evaluates the corresponding tag.
java xml web-services jaxb cxf
membersound
source share