SpringBoot结合cxf自动生成webservice客户端代码插件

SpringBoot结合cxf自动生成webservice客户端代码插件

一、创建Maven项目

二、引入CXF的插件依赖

<?xml version="1.0" encoding="UTF-8"?>



test
test
0.0.1-SNAPSHOT

4.0.0

<artifactId>type-generator</artifactId>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cxf.version>3.2.6</cxf.version>
</properties>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <encoding>UTF-8</encoding>
                        <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                        <!--<sourceRoot>src/main/java</sourceRoot>-->
                        <defaultOptions>
                            <extraargs>
                                <extraarg>-impl</extraarg>
                                <extraarg>-verbose</extraarg>
                                <extraarg>-validate</extraarg>
                                <extraarg>-client</extraarg>
                            </extraargs>
                        </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>http://0.0.0.0:8080/services/getWeatherService?wsdl</wsdl>
                                <!--<wsdl>D:\code\Demo\src/main/resources/HVSService.wsdl</wsdl>-->
                                <extraargs>
                                    <extraarg>-p</extraarg>
                                    <extraarg>xxx.xxx.xxx.xxx.xxx</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

注:如果有现成的WSDL文件,可以将WSDL文件存放至项目指定目录,并配置好路径;

D:\code\Demo\src/main/resources/HVSService.wsdl

反之若是没有,可以通过服务url获取:

// 此为个人样板示例,仅供参考
localhost:8080/Service/HVSService.wsdl

三、Maven编译

最后在idea的maven终端编译即可 键入编译命令:mvn generate-sources

四、完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值