其他分享
首页 > 其他分享> > WebService简单使用教程

WebService简单使用教程

作者:互联网

根据说明书获取信息

代码示例:

 1 import com.gyf.weather.ws.ArrayOfString;
 2 import com.gyf.weather.ws.WeatherWS;
 3 import com.gyf.weather.ws.WeatherWSSoap;
 4 
 5 public class Main {
 6 
 7     public static void main(String[] args) {
 8 
 9         //由下向上看,先找到说明书中的服务WeatherWS
10         //获取服务
11         WeatherWS ws = new WeatherWS();
12         //获取端口
13         WeatherWSSoap soap = ws.getPort(WeatherWSSoap.class);
14 
15         //1.获得国外国家名称和与之对应的ID
16 /*        ArrayOfString aos = soap.getRegionCountry();
17         for (String region : aos.getString()){
18             System.out.println(region);
19         }*/
20 
21         //2.获得支持的城市/地区名称和与之对应的ID
22         /*ArrayOfString aos = soap.getSupportCityString("吉林");
23         for (String city : aos.getString()){
24             System.out.println(city);
25         }*/
26 
27         //3.获取天气信息
28         ArrayOfString aos = soap.getWeather("吉林", "");
29         for (String item : aos.getString()){
30             System.out.println(item);
31         }
32 
33     }
34 }

 

标签:教程,WebService,ws,简单,aos,WeatherWS,soap,ArrayOfString,String
来源: https://www.cnblogs.com/116970u/p/11100324.html