java WSDL接口webService实现方式

本文介绍了使用JDK命令行工具wsimport生成WSDL对象类的方法,并提供了在Eclipse和MyEclipse中创建WSDL文件的步骤。此外还列举了进行WSDL操作时可能需要的一些Maven依赖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、使用JDK生成WSDL的对象类

  1、cmd进入JDK的bin文件中

    执行命令 wsimport -keep -p com.demo.client http://localhost:8080/Demo/services/MyService?wsdl

    比较常用的[options]有:

    1). -d <directory>
      在指定的目录生成class文件
    2). -clientjar <jarfile>
      在当前目录生成jar文件,结合-d <directory>可以在指定的目录生成jar文件
    3). -s <directory>
      在指定的目录生成java源文件
    4). -p <pkg>
      指定生成文件的包结构
    5). -keep
      在生成class文件,或者jar包时,同时保留java源文件
 
  2、eclipse生成WSDL文件

      在Eclipse中生成webservice客户端代码,New---->Other---->Webservice---->Webservice Client,选择之前拷贝到eclipse中的wsdl路径点击finish,这样eclipse就帮我们自动生成了webservice的客户端,接下来只需在程序中调用即可,在程序中调用     eclipse自动生成的webservice客户端;

  

  3、MyEclipse 生成 WSDL 文件

    在项目上右键,选择New->Other->Web Service->Web Service Client->Next,会看到以下界面:

 

  4、WSDL Maven支持的jar包

    
    <dependencies>
        <!-- ==================== WSDL 依赖文件   start=================== -->
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxrpc</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.soap</groupId>
            <artifactId>saaj-api</artifactId>
            <version>1.3.5</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.3</version>
        </dependency>
        <!-- ==================== WSDL 依赖文件   end====================== -->
    </dependencies>
  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值