webservice之wsdl文档解析

1.为什么要有webservice?

  • 解决跨语言,跨平台,远程调用的问题
  • 重要术语:
  1. WSDL:webservice define language
  2. SOAP:simple object access protocal(http+xml片段)
  3. SEI:webservice endpoint interface(终端)
  4. CXF:Celtix+XFire(一个框架)

2.wsdl(后面的序号代表查看顺序)

  • 它是基于schema约束写的xml文档
  • 五大组成部分:
  1. types: ⑤定义的schema约束
  2. message:④SEI中方法的请求与响应格式
  3. portType: ②各个webservice接口(SEI,由@WebService注解标识,方法用@WebMethod标识)
  4. binding: ③SEI的实现类
  5. service: ①这里是入口(webservice容器,找SEI接口)
  • 以下是一个天气查询的wsdl文档片段

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://WebXml.com.cn/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <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;天气预报 Web 服务,数据每2.5小时左右自动更新一次,准确可靠。包括 340 多个中国主要城市和 60 多个国外主要城市三日内的天气预报数据。&lt;/br&gt;此天气预报Web Services请不要用于任何商业目的,若有需要请&lt;a href="http://www.webxml.com.cn/zh_cn/contact_us.aspx" target="_blank"&gt;联系我们&lt;/a&gt;,欢迎技术交流。 QQ:8409035&lt;br /&gt;使用本站 WEB 服务请注明或链接本站:http://www.webxml.com.cn/ 感谢大家的支持&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#999999;"&gt;通知:天气预报 WEB 服务如原来使用地址 http://www.onhap.com/WebServices/WeatherWebService.asmx 的,请改成现在使用的服务地址 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ,重新引用即可。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;</wsdl:documentation>
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://WebXml.com.cn/">
      <s:complexType name="ArrayOfString">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
        </s:sequence>
      </s:complexType>
 <s:element name="getWeatherbyCityName">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="theCityName" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="getWeatherbyCityNameResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="getWeatherbyCityNameResult" type="tns:ArrayOfString" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ArrayOfString" nillable="true" type="tns:ArrayOfString" />
      <s:element name="DataSet" nillable="true">
        <s:complexType>
          <s:sequence>
            <s:element ref="s:schema" />
            <s:any />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>
<wsdl:message name="getWeatherbyCityNameSoapIn">
    <wsdl:part name="parameters" element="tns:getWeatherbyCityName" />
  </wsdl:message>
  <wsdl:message name="getWeatherbyCityNameSoapOut">
    <wsdl:part name="parameters" element="tns:getWeatherbyCityNameResponse" />
  </wsdl:message>
  <wsdl:message name="getWeatherbyCityNameHttpGetIn">
    <wsdl:part name="theCityName" type="s:string" />
  </wsdl:message>
  <wsdl:message name="getWeatherbyCityNameHttpGetOut">
    <wsdl:part name="Body" element="tns:ArrayOfString" />
  </wsdl:message>
  <wsdl:message name="getWeatherbyCityNameHttpPostIn">
    <wsdl:part name="theCityName" type="s:string" />
  </wsdl:message>
  <wsdl:message name="getWeatherbyCityNameHttpPostOut">
    <wsdl:part name="Body" element="tns:ArrayOfString" />
  </wsdl:message>
  <wsdl:portType name="WeatherWebServiceSoap">
    <wsdl:operation name="getWeatherbyCityName">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br&gt;&lt;h3&gt;根据城市或地区名称查询获得未来三天内天气情况、现在的天气实况、天气和生活指数&lt;/h3&gt;&lt;p&gt;调用方法如下:输入参数:theCityName = 城市中文名称(国外城市可用英文)或城市代码(不输入默认为上海市),如:上海 或 58367,如有城市名称重复请使用城市代码查询(可通过 getSupportCity 或 getSupportDataSet 获得);返回数据: 一个一维数组 String(22),共有23个元素。&lt;br /&gt;String(0) 到 String(4):省份,城市,城市代码,城市图片名称,最后更新时间。String(5) 到 String(11):当天的 气温,概况,风向和风力,天气趋势开始图片名称(以下称:图标一),天气趋势结束图片名称(以下称:图标二),现在的天气实况,天气和生活指数。String(12) 到 String(16):第二天的 气温,概况,风向和风力,图标一,图标二。String(17) 到 String(21):第三天的 气温,概况,风向和风力,图标一,图标二。String(22) 被查询的城市或地区的介绍 &lt;br /&gt;&lt;a href="http://www.webxml.com.cn/images/weather.zip"&gt;下载天气图标&lt;img src="http://www.webxml.com.cn/images/download_w.gif" border="0" align="absbottom" /&gt;&lt;/a&gt;(包含大、中、小尺寸) &lt;a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank"&gt;天气图例说明&lt;/a&gt; &lt;a href="http://www.webxml.com.cn/files/weather_eg.zip"&gt;调用此天气预报Web Services实例下载&lt;/a&gt; (VB ASP.net 2.0)&lt;/p&gt;&lt;br /&gt;</wsdl:documentation>
      <wsdl:input message="tns:getWeatherbyCityNameSoapIn" />
      <wsdl:output message="tns:getWeatherbyCityNameSoapOut" />
    </wsdl:operation>
   
  </wsdl:portType>
    <wsdl:operation name="getWeatherbyCityName">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br&gt;&lt;h3&gt;根据城市或地区名称查询获得未来三天内天气情况、现在的天气实况、天气和生活指数&lt;/h3&gt;&lt;p&gt;调用方法如下:输入参数:theCityName = 城市中文名称(国外城市可用英文)或城市代码(不输入默认为上海市),如:上海 或 58367,如有城市名称重复请使用城市代码查询(可通过 getSupportCity 或 getSupportDataSet 获得);返回数据: 一个一维数组 String(22),共有23个元素。&lt;br /&gt;String(0) 到 String(4):省份,城市,城市代码,城市图片名称,最后更新时间。String(5) 到 String(11):当天的 气温,概况,风向和风力,天气趋势开始图片名称(以下称:图标一),天气趋势结束图片名称(以下称:图标二),现在的天气实况,天气和生活指数。String(12) 到 String(16):第二天的 气温,概况,风向和风力,图标一,图标二。String(17) 到 String(21):第三天的 气温,概况,风向和风力,图标一,图标二。String(22) 被查询的城市或地区的介绍 &lt;br /&gt;&lt;a href="http://www.webxml.com.cn/images/weather.zip"&gt;下载天气图标&lt;img src="http://www.webxml.com.cn/images/download_w.gif" border="0" align="absbottom" /&gt;&lt;/a&gt;(包含大、中、小尺寸) &lt;a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank"&gt;天气图例说明&lt;/a&gt; &lt;a href="http://www.webxml.com.cn/files/weather_eg.zip"&gt;调用此天气预报Web Services实例下载&lt;/a&gt; (VB ASP.net 2.0)&lt;/p&gt;&lt;br /&gt;</wsdl:documentation>
      <wsdl:input message="tns:getWeatherbyCityNameHttpGetIn" />
      <wsdl:output message="tns:getWeatherbyCityNameHttpGetOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="WeatherWebServiceHttpPost">
    <wsdl:operation name="getWeatherbyCityName">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">&lt;br&gt;&lt;h3&gt;根据城市或地区名称查询获得未来三天内天气情况、现在的天气实况、天气和生活指数&lt;/h3&gt;&lt;p&gt;调用方法如下:输入参数:theCityName = 城市中文名称(国外城市可用英文)或城市代码(不输入默认为上海市),如:上海 或 58367,如有城市名称重复请使用城市代码查询(可通过 getSupportCity 或 getSupportDataSet 获得);返回数据: 一个一维数组 String(22),共有23个元素。&lt;br /&gt;String(0) 到 String(4):省份,城市,城市代码,城市图片名称,最后更新时间。String(5) 到 String(11):当天的 气温,概况,风向和风力,天气趋势开始图片名称(以下称:图标一),天气趋势结束图片名称(以下称:图标二),现在的天气实况,天气和生活指数。String(12) 到 String(16):第二天的 气温,概况,风向和风力,图标一,图标二。String(17) 到 String(21):第三天的 气温,概况,风向和风力,图标一,图标二。String(22) 被查询的城市或地区的介绍 &lt;br /&gt;&lt;a href="http://www.webxml.com.cn/images/weather.zip"&gt;下载天气图标&lt;img src="http://www.webxml.com.cn/images/download_w.gif" border="0" align="absbottom" /&gt;&lt;/a&gt;(包含大、中、小尺寸) &lt;a href="http://www.webxml.com.cn/zh_cn/weather_icon.aspx" target="_blank"&gt;天气图例说明&lt;/a&gt; &lt;a href="http://www.webxml.com.cn/files/weather_eg.zip"&gt;调用此天气预报Web Services实例下载&lt;/a&gt; (VB ASP.net 2.0)&lt;/p&gt;&lt;br /&gt;</wsdl:documentation>
      <wsdl:input message="tns:getWeatherbyCityNameHttpPostIn" />
      <wsdl:output message="tns:getWeatherbyCityNameHttpPostOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WeatherWebServiceSoap" type="tns:WeatherWebServiceSoap">
    <wsdl:operation name="getWeatherbyCityName">
      <soap:operation soapAction="http://WebXml.com.cn/getWeatherbyCityName" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="WeatherWebServiceSoap12" type="tns:WeatherWebServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="getWeatherbyCityName">
      <soap12:operation soapAction="http://WebXml.com.cn/getWeatherbyCityName" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    
  </wsdl:binding>
  <wsdl:binding name="WeatherWebServiceHttpGet" type="tns:WeatherWebServiceHttpGet">
    <http:binding verb="GET" />
    <wsdl:operation name="getWeatherbyCityName">
      <http:operation location="/getWeatherbyCityName" />
      <wsdl:input>
        <http:urlEncoded />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="WeatherWebServiceHttpPost" type="tns:WeatherWebServiceHttpPost">
    <http:binding verb="POST" />
    
    <wsdl:operation name="getWeatherbyCityName">
      <http:operation location="/getWeatherbyCityName" />
      <wsdl:input>
        <mime:content type="application/x-www-form-urlencoded" />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="WeatherWebService">
    <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;天气预报 Web 服务,数据每2.5小时左右自动更新一次,准确可靠。包括 340 多个中国主要城市和 60 多个国外主要城市三日内的天气预报数据。&lt;/br&gt;此天气预报Web Services请不要用于任何商业目的,若有需要请&lt;a href="http://www.webxml.com.cn/zh_cn/contact_us.aspx" target="_blank"&gt;联系我们&lt;/a&gt;,欢迎技术交流。 QQ:8409035&lt;br /&gt;使用本站 WEB 服务请注明或链接本站:http://www.webxml.com.cn/ 感谢大家的支持&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#999999;"&gt;通知:天气预报 WEB 服务如原来使用地址 http://www.onhap.com/WebServices/WeatherWebService.asmx 的,请改成现在使用的服务地址 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ,重新引用即可。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;</wsdl:documentation>
    <wsdl:port name="WeatherWebServiceSoap" binding="tns:WeatherWebServiceSoap">
      <soap:address location="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" />
    </wsdl:port>
    <wsdl:port name="WeatherWebServiceSoap12" binding="tns:WeatherWebServiceSoap12">
      <soap12:address location="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" />
    </wsdl:port>
    <wsdl:port name="WeatherWebServiceHttpGet" binding="tns:WeatherWebServiceHttpGet">
      <http:address location="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" />
    </wsdl:port>
    <wsdl:port name="WeatherWebServiceHttpPost" binding="tns:WeatherWebServiceHttpPost">
      <http:address location="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值