---
title: "maven 生成webservice客户端代码"
author: "yangjayup"
date: "2016-12-08T18:34:31Z"
tags: ["WebService", "maven"]
categories: ["编程语言"]
slug: "maven-webservice"
draft: false
lastmod: "2016-12-08T18:36:55Z"
id: 2343800
url: "https://yangjayup.iteye.com/blog/2343800"
---

```
<dependencies>  
        <dependency>  
            <groupId>junit</groupId>  
            <artifactId>junit</artifactId>  
            <version>4.10</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-transports-http</artifactId>  
            <version>${cxf.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.apache.cxf</groupId>  
            <artifactId>cxf-rt-transports-http-jetty</artifactId>  
            <version>${cxf.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-context</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-web</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.eclipse.jetty</groupId>  
            <artifactId>jetty-webapp</artifactId>  
            <version>8.1.11.v20130520</version>  
        </dependency>  
  
    </dependencies> 
    <build>  
        <finalName>cxf-date</finalName>  
          
        <plugins>  
            <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>src/main/resources/cxf</sourceRoot><!--就是生成文件存放的位置；可用这个表示项目路径，和下面的extraarg的包路径相结合${project.build.sourceDirectory}-->  
                            <wsdlOptions>  
                                <wsdlOption>  
                                    <wsdl>***?wsdl</wsdl> 
                                    <frontEnd>jaxws21</frontEnd>  
                                    <faultSerialVersionUID>1</faultSerialVersionUID>  
                                            <extraargs>
                                                <extraarg>-impl</extraarg>
                                                <extraarg>-client</extraarg>
                                                <extraarg>-p</extraarg>
 
                                                <!--这里为webservice的包指定到项目里的包目录-->                                         
                                                <extraarg>
                                                    http://www.opentravel.org/OTA/2003/05=com.test.ws.a
                                                </extraarg>
                                                <extraarg>-p</extraarg>
                                                <extraarg>
                                                    http://htng.org/2014B=com.test.ws.b
                                                </extraarg>
                                            </extraargs>
                                </wsdlOption>  
                            </wsdlOptions>  
                        </configuration>  
                        <goals>  
                            <goal>wsdl2java</goal>  
                        </goals>  
                    </execution>  
                </executions>  
            </plugin>  
        </plugins>  
    </build>
```