3

I am trying to change the class names of cxf generated source from an inline WSDL. The bindings I specify using xpath keeps getting ignored.

Below is my binding file:

<jaxws:bindings
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    targetNamespace="http://www.example.org/Small/"
    version="1.0">

    <jaxb:bindings node="//xsd:element[@name='NewOperationRequest']">
      <jaxb:class name="xyz"/>
    </jaxb:bindings>
</jaxws:bindings>

Below is my wsdl file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/Small/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Small" targetNamespace="http://www.example.org/Small/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.org/Small/">
      <xsd:element name="NewOperationX">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="in" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="NewOperationResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="out" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="NewOperationRequest">
    <wsdl:part element="tns:NewOperationX" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="NewOperationResponse">
    <wsdl:part element="tns:NewOperationResponse" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="Small">
    <wsdl:operation name="NewOperation">
      <wsdl:input message="tns:NewOperationRequest"/>
      <wsdl:output message="tns:NewOperationResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="SmallSOAP" type="tns:Small">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="NewOperation">
      <soap:operation soapAction="http://www.example.org/Small/NewOperation"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Small">
    <wsdl:port binding="tns:SmallSOAP" name="SmallSOAP">
      <soap:address location="http://www.example.org/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

And below is my cxf pom plugin:

     <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
            <execution>
                <configuration>
                    <sourceRoot>
                        target/generated-sources
                    </sourceRoot>
                    <wsdlOptions>
                        <wsdlOption>
                            <wsdl>${basedir}/src/main/webapp/WEB-INF/wsdl/small.wsdl</wsdl>
                            <bindingFiles>
                               <bindingFile>${basedir}/src/main/webapp/WEB-INF/wsdl/small.xjb</bindingFile>
                             </bindingFiles>
                        </wsdlOption>
                    </wsdlOptions>
                </configuration>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

I wasn't able to find an example of custom bindings for inline WSDLs using CXF. Any help is appreciated. Thanks,

Brown
  • 61
  • 1
  • 2
  • 8

1 Answers1

0

I think you have a namespace issue here. Your inner binding needs to be a jaxws binding rather than a jaxb binding.

Try the following as your innermost binding instead of your <jaxb:bindings> element (I've also modified your xpath):

<jaxws:bindings node="wsdl:definitions/wsdl:message[@name='NewOperationRequest']">
        <class name="xyz"/>
</jaxws:bindings>       

There's a similar example that renames a porttype on the Apache CXF site under the JAXWS Customization section.

For more options, here's a link on GitHub to a JAX-WS sample binding file demonstrating various parts of the wsdl you can customize.

roj
  • 1,262
  • 13
  • 27