首页 > 技术文章 > 如何看懂wsdl文件

haoxiu1004 2017-09-14 15:05 原文

解释下面代码:

<wsdl:service name="WeatherWS">

    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;a href="http://www.webxml.com.cn/" target="_blank"&gt;WebXml.com.cn&lt;/a&gt; &lt;strong&gt;2400多个城市天气预报Web服务&lt;/strong&gt;,包含2300个以上中国城市和100个以上国外城市天气预报数据。数据每2.5小时左右自动更新一次,准确可靠。&lt;br /&gt;使用本站 WEB 服务请注明或链接本站:&lt;a href="http://www.webxml.com.cn/" target="_blank"&gt;http://www.webxml.com.cn/&lt;/a&gt; 感谢大家的支持!&lt;br /&gt;&lt;br /&gt;&lt;img alt="PDF" title="PDF file" src="http://www.webxml.com.cn/images/icon/pdf.gif" style="vertical-align: middle;" /&gt; &lt;a href="http://www.webxml.com.cn/files/WeatherWsHelp.pdf" target="_blank"&gt;接口帮助文档&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /&gt; &lt;a href="http://www.webxml.com.cn/files/about_city.zip"&gt;部分城市介绍和气候背景&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="ZIP" title="ZIP file" src="http://www.webxml.com.cn/images/icon/zip.gif" style="vertical-align: middle;" /&gt; &lt;a href="http://www.webxml.com.cn/files/city_photo.zip"&gt;部分城市图片&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img alt="HTML" title="HTML file" src="http://www.webxml.com.cn/images/icon/html.gif" style="vertical-align: middle;" /&gt; &lt;a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank"&gt;天气现象和图例&lt;/a&gt;&lt;br /&gt;&amp;nbsp;</wsdl:documentation>

    <wsdl:port name="WeatherWSSoap" binding="tns:WeatherWSSoap">

      <soap:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />

    </wsdl:port>

    <wsdl:port name="WeatherWSSoap12" binding="tns:WeatherWSSoap12">

      <soap12:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />

    </wsdl:port>

    <wsdl:port name="WeatherWSHttpGet" binding="tns:WeatherWSHttpGet">

      <http:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />

    </wsdl:port>

    <wsdl:port name="WeatherWSHttpPost" binding="tns:WeatherWSHttpPost">

      <http:address location="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx" />

    </wsdl:port>

  </wsdl:service>

 

1、<wsdl:service name="WeatherWS"> 这个WeatherWS其实就是服务器端的service接口,这样的话在客户端就要通过这个new 一个接口工厂出来

    现在可以写一个测试类

  //new 对象生产SEI对象的

WeatherWS weatherWS = new WeatherWS();

 

//使用工厂调用出代理对象 WeatherWSSoap也是一个接口,这个时候就可以调用方法

WeatherWSSoap weatherWSSoap = weatherWS.getWeatherWSSoap();

 

//分装的list集合(String类型)

ArrayOfString weather = weatherWSSoap.getWeather("新沂", null);

 

List<String> list = weather.getString();

System.out.println(list);

    

此时结果显示在控制台

 

推荐阅读