0

I am struggling with the following problem: A SOAP webservice is defined via a WSDL like so:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:ns1="http://some.name.space" name="EnterpriseyName"
                  targetNamespace="http://some.other.name.space/">
    <wsdl:import
            location="http://testing.environment.my.company.com/EnterpriseyNameService?wsdl=Interface.wsdl"
            namespace="http://some.name.space">
    </wsdl:import>
    <wsdl:binding name="EnterpriseyNameServiceSoapBinding" type="ns1:MyRequestType">
        <!-- ... -->
    </wsdl:binding>
    <wsdl:service name="EnterpriseyNameService">
        <!-- ... -->
    </wsdl:service>
</wsdl:definitions>

and the XSD for the necessary types is embedded inside Interface.wsdl:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                  xmlns:ns1="http://some.name.space" name="InterfaceWebFacade" 
                  targetNamespace="http://some.name.space">
<wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
               xmlns:tns="http://some.name.space"
               targetNamespace="http://some.name.space"
    elementFormDefault="qualified" ​version="1.0">

        <xs:complexType name="MyRequestType">`
        <!-- ... -->
        </xs:complexType>
        
        <xs:complexType name="ProblematicName">
            <xs:element name="problematicName">
                <xs:complexType>
                    <!-- ... -->
                </xs:complexType>
            </xs:element>
        </xs:complexType>
    </xs:schema>
</wsdl:types>
</wsdl:definitions>

I want to generate Java classes for it with CXF-codegen and the maven goal "wsdl2java". In my special case the embedded WSDL contains type declarations that clash with the defaults JAXB uses. Specifically, it is the same element-vs-anonymous-complex-type name clash that also occurs in this question: The complex type ProblematicName get translated to a java class named ProblematicName by JAXB which contains a field named problematicName whose anonymous complex type gets translated to an inner class which is named the same as the field up to capitalization, leading to an inner class also named ProblematicName which is impossible in Java and which JAXB therefore refused to generate.

Going by the answer on that and similar questions, I tried to define a bindings.xml file like in this answer

<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
               ​xmlns:xs="http://www.w3.org/2001/XMLSchema"
               ​xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
               ​xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
                    ​<!-- vvv XPath problem here vvv -->
   ​<jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[1]">
       ​<jxb:bindings node="//xs:element[@name='ProblematicName']/complexType">
            ​<jxb:class name="AlternativeName"/>
       ​</jxb:bindings>

   ​</jaxws:bindings>
</jaxws:bindings>

The problem however is that I need to address elements in the embedded Interface.wsdl, not the outer EnterpriseyNameService.wsdl, but only the outer WSDL defines all the things that are necessary to generate all the classes.

I could not find any information on how to go about that.

EDIT: Things I've tried - I played with the wsdlLocation attribute. I tried stacking two jaxws:bindings elements, one addressed to the wsdlimport, the other to the problematic elements in the embedded wsdl. I tried several combinations of that.

Johannes Hahn
  • 324
  • 3
  • 15

0 Answers0