网上免费的webService接口网址:http://www.webxml.com.cn/zh_cn/index.aspx
1、通过http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl获取天气预报的wsdl的文档,并保存到本地。
2、通过cmd命令,在项目src目录下,执行wsimport -keep url命令。
3、刷新项目生成如下代码
案例:天气预报的接口调用
4、客户端调用代码

public class weatherClient {
	public static void main(String[] args) {
		WeatherWS weatherWS = new WeatherWS();
		WeatherWSSoap weatherWSSoap = weatherWS.getWeatherWSSoap();
		ArrayOfString weather = weatherWSSoap.getWeather("北京",null);
		List<String> list = weather.getString();
		for(String s : list) {
			System.out.println(s + "****************");
		}
	}
}

备注:java调用net的webservice接口的问题
需要将wsdl文档中<s:element ref="s:schema" /> <s:any />部分内容替换成<s:any minOccurs="2" maxOccurs="2"/>

相关文章:

  • 2021-11-18
  • 2021-11-17
  • 2021-11-17
  • 2021-07-06
  • 2021-03-27
猜你喜欢
  • 2021-10-19
  • 2021-10-19
  • 2021-11-16
  • 2021-11-28
  • 2021-11-07
相关资源
相似解决方案