CXF codegen-plugin无效

时间:2016-09-11 09:06:55

标签: web-services maven wsdl cxf codegen

我试图让cxf-codegen-plugin从我的wsdl文件生成源代码。 但是当我用eclipse luna执行 mvn generate-source 时没有任何事情发生。 看起来插件本身配置不正确。

我的pom.xml

        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.webservice</groupId>
    <artifactId>wsdlfirstwebservice</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>wsdlfirstwebservice Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <jdk.version>1.8</jdk.version>
        <cxf.version>3.0.4</cxf.version>
        <jaxb.version>2.2</jaxb.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>${cxf.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>${jaxb.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>${jaxb.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>3.0.4</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>Wrsdlfirstwebservice</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                    </configuration>
                </plugin>


                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>${cxf.version}</version>
                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                                <wsdlOptions>
                                    <wsdlOption>
                                        <wsdl>src/main/resources/CustomerOrders.wsdl</wsdl>
                                        <bindingFiles>
                                            <bindingFile>src/main/resources/wsdl/binding.xml</bindingFile>
                                        </bindingFiles>
                                    </wsdlOption>
                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>com.sun.xml.bind</groupId>
                            <artifactId>jaxb-impl</artifactId>
                            <version>${jaxb.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>com.sun.xml.bind</groupId>
                            <artifactId>jaxb-xjc</artifactId>
                            <version>${jaxb.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

我的wsdl

<?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions name="CustomerOrdersService"   
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:tns="http://www.wsdlfirstwebservice.com/customerorders"   
       targetNamespace="http://www.wsdlfirstwebservice.com/customerorders">
        <!-- Types -->
        <wsdl:types>
            <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:tns="http://www.wsdlfirstwebservice.com/customerorders"
                targetNamespace="http://www.wsdlfirstwebservice.com/customerorders">

                <xs:complexType name="order">
                    <xs:sequence>
                        <xs:element name="id" type="xs:integer"/>
                        <xs:element name="product" type="tns:product" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
                <xs:complexType name="product">
                    <xs:sequence>
                        <xs:element name="id" type="xs:integer" minOccurs="0"/>
                        <xs:element name="description" type="xs:string" minOccurs="0"/>
                        <xs:element name="quantity" type="xs:integer" minOccurs="0"/>                   
                    </xs:sequence>
                </xs:complexType>
                <xs:complexType name="getOrdersRequest">
                    <xs:sequence>
                        <xs:element name="customerId" type="xs:integer" minOccurs="0"/> 
                    </xs:sequence>
                </xs:complexType>
                 <xs:complexType name="getOrdersResponse">
                    <xs:sequence>
                        <xs:element name="order" type="tns:order" minOccurs="0" maxOccurs="unbounded"/> 
                    </xs:sequence>
                </xs:complexType>

                <xs:element name="getOrdersRequest" type="tns:getOrdersRequest"/>
                <xs:element name="getOrdersResponse" type="tns:getOrdersResponse"/>

            </xs:schema>
        </wsdl:types>

        <!-- Messages :
        These are analogous to method parameters and return types in java methods
        -->
        <wsdl:message name="getOrdersRequest">
            <wsdl:part name="parameters" element="tns:getOrdersRequest">
            </wsdl:part>
        </wsdl:message>
        <wsdl:message name="getOrdersResponse">
            <wsdl:part name="parameters" element="tns:getOrdersResponse">
            </wsdl:part>
        </wsdl:message>

        <!-- Port types 
        These are analogous to java methods.  Port types use message as input and/or output.
         -->
        <wsdl:portType name="CustomerOrdersPortType">
            <wsdl:operation name="getOrders">
                <wsdl:input name="getOrdersRequest" message="tns:getOrdersRequest"></wsdl:input>
                <wsdl:output name="getOrdersResponse" message="tns:getOrdersResponse"></wsdl:output>
            </wsdl:operation>
        </wsdl:portType>

        <!-- Bindings 
            This defines the message formats and protocol details for web service
         -->
         <wsdl:binding name="CustomerOrdersServiceSoapBinding" type="tns:CustomerOrdersPortType">
            <soap:binding style="document"  transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="getOrders">
                <soap:operation soapAction="" style="document"/>
                <wsdl:input name="getOrdersRequest">
                    <soap:body use="literal"/>
                </wsdl:input>
                <wsdl:output name="getOrdersResponse">
                    <soap:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>
         </wsdl:binding>

         <!-- Service
         Tells customer how to consume the service
          -->
         <wsdl:service name="CustomerOrdersService">
            <wsdl:port name="CustomerOrdersPort" binding="tns:CustomerOrdersServiceSoapBinding">
                <soap:address location="http://localhost:8080/wsdlfirstwebservice/services/CustomerOrdersService"/>
            </wsdl:port>
         </wsdl:service>
     </wsdl:definitions>

控制台输出

  

Apache Maven 3.2.1(ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9;   2014-02-14T23:07:52 + 05:30)Maven home:   D:\ JSPractice \ wsdlfirstwebservice \ EMBEDDED Java版本:1.8.0_60,   供应商:Oracle Corporation Java home:C:\ Program Files   (x86)\ Java \ jdk1.8.0_60 \ jre默认语言环境:en_IN,平台编码:   Cp1252操作系统名称:&#34; Windows 7&#34;,版本:&#34; 6.1&#34;,arch:&#34; x86&#34;,系列:   &#34; DOS&#34; [INFO]错误堆栈跟踪已打开。 [DEBUG]阅读全球   来自EMBEDDED \ conf \ settings.xml [DEBUG]的设置读取用户设置   来自C:\ Users \ D.Sama.m2 \ settings.xml [DEBUG]使用本地存储库   在C:\ Users \ D.Sama.m2 \ repository [DEBUG]使用manager   EnhancedLocalRepositoryManager优先级为10.0   C:\ Users \ D.Sama.m2 \ repository [INFO]扫描项目... [DEBUG]   项目的扩展领域   com.webservice:wsdlfirstwebservice:war:0.0.1-SNAPSHOT :( none)[DEBUG]   查找包装战争的生命周期映射   ClassRealm [plexus.core,parent:null] [DEBUG] === REACTOR BUILD PLAN   ================================================ [DEBUG ]项目:com.webservice:wsdlfirstwebservice:war:0.0.1-SNAPSHOT [DEBUG]任务:
  [generate-sources] [DEBUG]风格:常规[DEBUG]   ================================================== ===================== [INFO] [INFO]使用构建器   org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder   线程数为1 [INFO]
  [信息]   -------------------------------------------------- ---------------------- [INFO]构建wsdlfirstwebservice Maven Webapp 0.0.1-SNAPSHOT [INFO]   -------------------------------------------------- ---------------------- [DEBUG]生命周期默认 - &gt; [验证,初始化,生成源,   流程源,生成资源,流程资源,编译,   流程类,生成测试源,流程测试源,   generate-test-resources,process-test-resources,test-compile,   流程测试类,测试,准备包,包,   预集成测试,集成测试,集成后测试,验证,   安装,部署] [DEBUG]生命周期清理 - &gt; [预先清洁,干净,   post-clean] [DEBUG]生命周期网站 - &gt; [pre-site,site,post-site,   site-deploy] [DEBUG] ===项目建设计划   ================================================ [DEBUG ]项目:com.webservice:wsdlfirstwebservice:0.0.1-SNAPSHOT [DEBUG]依赖项   (收集):[] [DEBUG]依赖关系(解析):[] [DEBUG]存储库   (依赖):[central(http://repo.maven.apache.org/maven2,   发布)] [DEBUG]存储库(插件):[中央   (http://repo.maven.apache.org/maven2,发布)] [调查]   ================================================== ===================== [INFO]   -------------------------------------------------- ---------------------- [INFO]建立成功[信息]   -------------------------------------------------- ---------------------- [INFO]总时间:0.101秒[INFO]完成时间:

     

2016-09-11T14:27:19 + 05:30 [INFO]最终记忆:4M / 15M [INFO]

1 个答案:

答案 0 :(得分:1)

您需要在构建/插件部分中放置cxf-codegen插件,而不仅仅是在build / pluginManagement / plugins中。

相关问题