Cxf codegen plugin WSDL-cxf自定义绑定

Cxf codegen plugin WSDL-cxf自定义绑定,cxf-codegen-plugin,Cxf Codegen Plugin,我正试图从内联WSDL更改cxf生成的源的类名。我使用xpath指定的绑定一直被忽略 下面是我的绑定文件: <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.co

我正试图从内联WSDL更改cxf生成的源的类名。我使用xpath指定的绑定一直被忽略

下面是我的绑定文件:

<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>

下面是我的wsdl文件:

<?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>

下面是我的cxf pom插件:

     <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>

org.apache.cxf
cxf-codegen插件
3.2.0
目标/生成源
${basedir}/src/main/webapp/WEB-INF/wsdl/small.wsdl
${basedir}/src/main/webapp/WEB-INF/wsdl/small.xjb
wsdl2java

我找不到使用CXF的内联WSDL的自定义绑定示例。感谢您的帮助。谢谢,

我认为您在这里遇到了名称空间问题。您的内部绑定需要是jaxws绑定,而不是jaxb绑定

尝试将以下内容作为最内部的绑定,而不是
元素(我还修改了xpath):


在JAXWS定制部分下,有一个类似的示例重命名了上的porttype

关于更多选项,这里有一个GitHub上的链接,链接到一个演示您可以自定义的wsdl的各个部分

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