ServiceDescription 類別

定義

提供方法建立和格式化具有適當命名空間 (Namespace)、項目和屬性 (Attribute) 的有效 Web 服務描述語言 (WSDL) 文件檔案,以便用於描述 XML Web Service。 此類別無法獲得繼承。

C#
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class ServiceDescription : System.Web.Services.Description.DocumentableItem
C#
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class ServiceDescription : System.Web.Services.Description.NamedItem
繼承
ServiceDescription
繼承
ServiceDescription
屬性

範例

下列範例示範如何建立 ServiceDescription 類別的執行個體。

C#
// Obtain the ServiceDescription of existing Wsdl.
ServiceDescription myDescription = ServiceDescription.Read("MyWsdl_CS.wsdl");
// Remove the Binding from the Binding Collection of ServiceDescription.
BindingCollection myBindingCollection = myDescription.Bindings;
myBindingCollection.Remove(myBindingCollection[0]);

// Form a new Binding.
Binding myBinding = new Binding();
myBinding.Name = "Service1Soap";
XmlQualifiedName myXmlQualifiedName =
                     new XmlQualifiedName("s0:Service1Soap");
myBinding.Type = myXmlQualifiedName;

SoapBinding mySoapBinding = new SoapBinding();
mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding.Style = SoapBindingStyle.Document;

OperationBinding addOperationBinding =
       CreateOperationBinding("Add",myDescription.TargetNamespace);
myBinding.Operations.Add(addOperationBinding);
myBinding.Extensions.Add(mySoapBinding);

// Add the Binding to the ServiceDescription.
myDescription.Bindings.Add(myBinding);
myDescription.Write("MyOutWsdl.wsdl");

備註

您可以使用 關鍵字或靜態 Read 方法來建立 new 這個類別的實例,這個方法會剖析 WSDL 檔案,並將其值指派給類別的適當成員。

WSDL 是以 XML 為基礎的語言,用於描述 XML Web 服務。 類別 ServiceDescription 會對應至 WSDL 檔案的根項目 definitions 。 如需 WSDL 的詳細資訊,請參閱 WSDL 規格。

建構函式

ServiceDescription()

初始化 ServiceDescription 類別的新執行個體。

欄位

Namespace

XML 命名空間,其中定義了 ServiceDescription 類別 ("http://schemas.xmlsoap.org/wsdl/")。 這個欄位為常數。

屬性

Bindings

取得包含於 Binding 中的 ServiceDescription 項目的集合。

Documentation

取得或設定 DocumentableItem 的執行個體的文字文件。

(繼承來源 DocumentableItem)
DocumentationElement

取得或設定 DocumentableItem 的文件項目。

(繼承來源 DocumentableItem)
ExtensibleAttributes

取得或設定型別 XmlAttribute 的陣列,表示符合 Web 服務互通性 (WS-I) Basic Profile 1.1 的 WSDL 屬性擴充。

(繼承來源 DocumentableItem)
Extensions

取得包含在 ServiceDescription 中的擴充性項目集合。

Imports

取得包含於 Import 中的 ServiceDescription 項目的集合。

Messages

取得包含於 Message 中的 ServiceDescription 項目的集合。

Name

取得或設定封入 Web 服務描述語言 (WSDL) 檔案之 描述 標記的 XML 名稱屬性。

Name

取得或設定項目的名稱。

(繼承來源 NamedItem)
Namespaces

取得或設定命名空間前置詞和命名空間的字典,用於在建構 ServiceDescription 物件時保留命名空間前置詞和命名空間。

(繼承來源 DocumentableItem)
PortTypes

取得包含於 PortType 中的 ServiceDescription 項目的集合。

RetrievalUrl

取得或設定套用 ServiceDescription 執行個體之 XML Web Service 的 URL。

Schema

取得與這個 ServiceDescription 相關聯的結構描述。

Serializer

取得 XML 序列化程式,用於在 ServiceDescription 物件與 Web 服務描述語言 (WSDL) 文件之間,進行序列化和還原序列化。

ServiceDescriptions

取得其 ServiceDescriptionCollection 為成員的 ServiceDescription 執行個體。

Services

取得包含在 Service 中的 ServiceDescription 執行個體集合。

TargetNamespace

取得或設定封入 Web 服務描述語言 (WSDL) 檔案之 targetNamespace 標記的 XML descriptions 屬性。

Types

取得或設定由 Types 包含的 ServiceDescription

ValidationWarnings

取得 StringCollection,包含在呼叫 Read(Stream, Boolean)Read(TextReader, Boolean)Read(String, Boolean)Read(XmlReader, Boolean) 時,validate 參數設定為 true 之下所產生的所有驗證警告。

方法

CanRead(XmlReader)

取得值,指出 XmlReader 是否表示可以剖析的有效 Web 服務描述語言 (WSDL) 檔案。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Read(Stream)

藉由從 ServiceDescription 執行個體直接載入 XML,初始化 Stream 類別的執行個體。

Read(Stream, Boolean)

藉由從 ServiceDescription 執行個體直接載入 XML,初始化 Stream 類別的執行個體。

Read(String)

藉由從指定的檔案直接載入 XML,初始化 ServiceDescription 物件的執行個體。

Read(String, Boolean)

藉由從指定的檔案直接載入 XML,初始化 ServiceDescription 物件的執行個體。

Read(TextReader)

藉由從 ServiceDescription 直接載入 XML,初始化 TextReader 類別的執行個體。

Read(TextReader, Boolean)

藉由從 ServiceDescription 直接載入 XML,初始化 TextReader 類別的執行個體。

Read(XmlReader)

藉由從 ServiceDescription 直接載入 XML,初始化 XmlReader 類別的執行個體。

Read(XmlReader, Boolean)

藉由從 ServiceDescription 直接載入 XML,初始化 XmlReader 類別的執行個體。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
Write(Stream)

ServiceDescription 寫出至指定的 Stream

Write(String)

ServiceDescription 做為 Web 服務描述語言 (WSDL) 檔案寫出至指定的路徑。

Write(TextWriter)

ServiceDescription 做為 Web 服務描述語言 (WSDL) 檔案寫出至 TextWriter

Write(XmlWriter)

ServiceDescription 做為 Web 服務描述語言 (WSDL) 檔案寫出至 XmlWriter

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8