一個完整的WSDL文檔及各標簽詳解

来源:http://www.cnblogs.com/ChrisMurphy/archive/2016/02/28/5224314.html
-Advertisement-
Play Games

<?xml version="1.0" encoding="UTF8" ?> <wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" xmlns:soapenc12="http://www.w3.org/


<?xml version="1.0" encoding="UTF8" ?>

<wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" xmlns:soapenc12="http://www.w3.org/2003/05/soapencoding" xmlns:tns="http://www.57market.com.cn/HelloService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soapenvelope">

 

/**

 * type元素,定義了交換信息的數據格式。

 * 為了實現最大的互操作性(interoperability)和平臺中立性(neutrality),WSDL選用XML Schema DataTypes

 * 簡稱XSD作為標準類型系統,並將它作為固有類型系統。

 * 下麵是數據定義部分,該部分定義了兩個元素,一個是sayHello,一個是sayHelloResponse:

 * sayHello:定義了一個複雜類型,僅僅包含一個簡單的字元串,將來用來描述操作的參入傳入部分;

 * sayHelloResponse:定義了一個複雜類型,僅僅包含一個簡單的字元串,將來用來描述操作的返回值;

 */

<wsdl:types>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.57market.com.cn/HelloService">

       

       <xsd:element name="sayHello">

  <xsd:complexType>

<xsd:sequence>

  <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />

  </xsd:sequence>

  </xsd:complexType>

</xsd:element>

 

<xsd:element name="sayHelloResponse">

<xsd:complexType>

 <xsd:sequence>

  <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />

  </xsd:sequence>

     </xsd:complexType>

  </xsd:element>

 

  </xsd:schema>

  </wsdl:types>

 

/**

 * message元素指定XML 數據類型組成消息的各個部分。message元素用於定義操作的輸入和輸出參數。

 * 該部分是信息格式的抽象定義:定義了兩個消息sayHelloResponse和sayHelloRequest:

 * sayHelloRequest:sayHello操作的請求消息格式,由一個消息片斷組成,名字為parameters,

 * 元素是我們前面定義的 types中的元素;

 * sayHelloResponse:sayHello操作的響應消息格式,由一個消息片斷組成,名字為parameters,

 * 元素是我們前面定義 *的types中的元素;

 * 如果採用RPC樣式的消息傳遞,只需要將文檔中的element元素應以修改為type即可。

*message:用來定義消息的結構

*part:指定引用types中定義的標籤片斷

 */

<wsdl:message name="sayHelloRequest">

     <wsdl:part name="parameters" element="tns:sayHello" />

 </wsdl:message>

 

<wsdl:message name="sayHelloResponse">

     <wsdl:part name="parameters" element="tns:sayHelloResponse" />

 </wsdl:message>

 

/**

 * portType元素中定義了Web服務的操作。操作定義了輸入和輸出數據流中可以出現的XML消息。

 * 一些抽象操作的集合。每個操作關聯一個輸入消息和一個輸出消息。

 * portType定義了服務的調用模式的類型,這裡包含一個操作sayHello方法,同時包含input和output表明

 * 該操作是一個 請求/響應模式,請求消息是前面定義的sayHelloRequest,

 * 響應消息是前面定義的 sayHelloResponse。input表示傳遞到Web服務的有效負載,

 * output消息表示傳遞給客戶的有效負載。

*portType:用來定義服務端的SEI

*operation:用來指定SEI中的處理請求的方法

*input:指定客戶端應用傳過來的數據,會引用上面的而定義的<message>

*output:指定服務端返回給客戶端的數據,會引用上面的而定義的<message>

 */

<wsdl:portType name="HelloServicePortType">

<wsdl:operation name="sayHello">

  <wsdl:input name="sayHelloRequest" message="tns:sayHelloRequest" />

  <wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse" />

  </wsdl:operation>

  </wsdl:portType>

 

/**

 * binding 元素描述特定服務介面的協議、數據格式、安全性和其它屬性。

 * 針對操作和portType中使用的消息指定實際的協議和數據格式規範。

*binding:用於定義SEI的實現類

*type屬性:引用上面的<portType>

*<soap:operation style="document" /> 綁定的數據是一個document(xml)

*operation:用來定義實現的方法

*<soap:operation style="document" /> 傳輸的是document(xml)

*input:指定客戶端應用傳過來的數據

*<soap:body use="literal" />:文本數據

*output:指定服務器端返回客戶端的數據

*<soap:body use="literal"/>:文本數據

 */

<wsdl:binding name="HelloServiceHttpBinding" type="tns:HelloServicePortType">

 

  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="sayHello">

  <wsdlsoap:operation soapAction="" />

<wsdl:input name="sayHelloRequest">

  <wsdlsoap:body use="literal" />

  </wsdl:input>

<wsdl:output name="sayHelloResponse">

  <wsdlsoap:body use="literal" />

  </wsdl:output>

  </wsdl:operation>

 

</wsdl:binding>

 

 

/**

 * service元素。服務元素包含一組port元素。埠將端點與來自服務介面定義的binding 元素關聯起來。

 * port指定一個綁定的地址,這樣定義一個通信的終端。

 *service:一個webservice的容器

 *name:屬性:它用以指定一個服務器端處理請求的入口(就是SEI的實現)

 * binding屬性:引用上面定義的<binding>

 *address:當前webservice的請求地址

 */

<wsdl:service name="HelloService">

      <wsdl:port name="HelloServiceHttpPort"binding="tns:HelloServiceHttpBinding">

    <soap:address location="http://localhost:8080/xfire/services/HelloService" />

  </wsdl:port>

 </wsdl:service>

 

</wsdl:definitions>

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...