java WSDL接口webService實現(xiàn)方式
一、使用JDK生成WSDL的對象類
1、cmd進入JDK的bin文件中
執(zhí)行命令 wsimport -keep -p com.demo.client http://localhost:8080/Demo/services/MyService?wsdl
比較常用的[options]有:
1). -d <directory>
在指定的目錄生成class文件
2). -clientjar <jarfile>
在當(dāng)前目錄生成jar文件,結(jié)合-d <directory>可以在指定的目錄生成jar文件
3). -s <directory>
在指定的目錄生成java源文件
4). -p <pkg>
指定生成文件的包結(jié)構(gòu)
5). -keep
在生成class文件,或者jar包時,同時保留java源文件
2、eclipse生成WSDL文件
在Eclipse中生成webservice客戶端代碼,New---->Other---->Webservice---->Webservice Client,選擇之前拷貝到eclipse中的wsdl路徑點擊finish,這樣eclipse就幫我們自動生成了webservice的客戶端,接下來只需在程序中調(diào)用即可,在程序中調(diào)用 eclipse自動生成的webservice客戶端;
3、MyEclipse 生成 WSDL 文件
在項目上右鍵,選擇New->Other->WebService->WebServiceClient->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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用.NET Core3.0創(chuàng)建一個Windows服務(wù)的方法
這篇文章主要介紹了使用.NET Core3.0創(chuàng)建一個Windows服務(wù)的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-04-04