我正在尝试让 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 主页:D:\JSPractice\wsdlfirstwebservice\EMBEDDED Java 版本:1.8.0_60,供应商:Oracle Corporation Java 主页:C:\ Program Files (x86)\Java\jdk1.8.0_60\jre 默认语言环境:en_IN,平台编码:Cp1252 操作系统名称:“windows 7”,版本:“6.1”,arch:“x86”,家族:“dos” [INFO ] 错误堆栈跟踪已打开。[调试] 从 EMBEDDED\conf\settings.xml 读取全局设置 [调试] 从 C:\Users\D.Sama.m2\settings.xml 读取用户设置 [调试] 使用 C:\Users\D.Sama 的本地存储库.m2\repository [DEBUG] 使用优先级为 10.0 的管理器 EnhancedLocalRepositoryManager 用于 C:\Users\D.Sama.m2\repository [INFO] 正在扫描项目... [DEBUG] 项目 com.webservice 的扩展领域:
[生成源] [DEBUG] 样式:常规 [DEBUG] ===================================== ==================================== [INFO] [INFO] 使用构建器 org.apache.maven。线程数为 1 [INFO] 的生命周期.internal.builder.singlethreaded.SingleThreadedBuilder
[信息] --------------------------------------------- ------------------------- [INFO] 构建 wsdlfirstwebservice Maven Webapp 0.0.1-SNAPSHOT [INFO] ---------- -------------------------------------------------- ------------ [DEBUG] 生命周期默认值-> [验证,初始化,生成源,流程源,生成资源,流程资源,编译,流程类,生成测试-源,过程测试源,生成测试资源,过程测试资源,测试编译,过程测试类,测试,准备包,包,预集成测试,集成测试,后-集成测试、验证、安装、部署] [DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean] [DEBUG] Lifecycle site -> [pre-site, site, post-site,站点部署] [调试] === 项目构建计划 ====================================== =========== [DEBUG] 项目:com.webservice:wsdlfirstwebservice:0.0.1-SNAPSHOT [DEBUG] 依赖项(收集):[] [DEBUG] 依赖项(解决):[] [DEBUG]存储库(依赖项):[中央(http://repo.maven.apache.org/maven2,发布)] [DEBUG] 存储库(插件):[中央(http://repo.maven.apache.org/maven2,发布)] [DEBUG] == ==================================================== ==================== [信息] ---------------------------- -------------------------------------------------------- [信息] 构建成功 [信息]------------------------------------------------ ------------------------ [INFO] 总时间:0.101 s [INFO] 完成时间:2016-09-11T14:27:19+05:30 [INFO] 最终内存:4M/15M [INFO]