使用jdk自带的wsimport工具生成代理类
c:\Program Files\Java\jdk1.8.0_121\bin>wsimport -keep -encoding utf-8 -d d:\ -s d:\src -verbose http://192.168.61.193/WeatherWebServiceJTB/WebService_Out.asmx?WSDL
-keep 保留生成的文件
-d 指定输出文件的目录
-s 输出源文件的目录
-verbose 显示过程输出
调用例子
public static void main(String[] args) throws Exception { String strUrl = "http://192.168.61.193/WebService/WeatherService_Out.asmx"; URL url = new URL(strUrl); WeatherService service = new WeatherService(url); WeatherServiceSoap client = service.getWeatherServiceSoap(); boolean b = client.testConnection(); String strVer = client.getCurrentVer(); System.out.println(strVer); }