您的位置:首页 > 其它

webservice生成客户端的两种简单方式

2016-09-20 22:41 351 查看
转:http://blog.csdn.net/zshake/article/details/9120403

 

1、1.6之后jdk自带了wsimport

wsimport -d D:\JavaEE\webservice -verbose -p cn.com.sparknet.blsp.service.client -keep 
http://192.168.1.177:5555/blsp-service/services/BLSPService?wsdl
-keep是生成java源代码

-d 生成的目录位置

-verbose 生成过程的详细信息展示

 

2、cxf的bin目录下有wsdl2java

wsdl2java -d D:\JavaEE\webservice -verbose -p cn.com.sparknet.blsp.service.client -keep 

http://192.168.1.177:5555/blsp-service/services/BLSPService?wsdl

-keep是生成java源代码

-d 生成的目录位置

-verbose 生成过程的详细信息展示

 

感觉两种方式类似,第二种可以再maven中使用 在客户端的pom.xml中添加

[html]
view plain
copy
print?

<build>  
        <plugins>  
            <plugin>  
                <groupId>org.apache.cxf</groupId>  
                <artifactId>cxf-codegen-plugin</artifactId>  
                <version>2.5.0</version>  
                <executions>  
                    <execution>  
                        <id>generate-sources</id>  
                        <phase>generate-sources</phase>  
                        <configuration>  
                            <sourceRoot>d://webservice//cxf</sourceRoot>  
                            <wsdlOptions>  
                                <wsdlOption>  
                                  <wsdl>http://localhost:9000/helloWorld?wsdl</wsdl>  
                                    <extraargs>  
                                        <extraarg>-verbose</extraarg>  



<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>d://webservice//cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>http://localhost:9000/helloWorld?wsdl</wsdl>
<extraargs>
<extraarg>-verbose</extraarg>

 

[html]
view plain
copy
print?

                                    <extraarg>-keep</extraarg>  
                              </extraargs>  
                            </wsdlOption>  
                        </wsdlOptions>  
                    </configuration>  
                    <goals>  
                        <goal>wsdl2java</goal>  
                    </goals>  
                </execution>  
            </executions>  
        </plugin>  
    </plugins>  
</build>  



<extraarg>-keep</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

 

 

右键单击pom.xml run as maven build 输入 clean compile 会在d://webservice//cxf目录下生成所需的java代码

更多的wsdl2java操作请参见http://cxf.apache.org/docs/wsdl-to-java.html

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: