Port 類別

定義

定義包含於 XML Web Service 中的個別端點。 此類別無法獲得繼承。

public ref class Port sealed : System::Web::Services::Description::DocumentableItem
public ref class Port sealed : System::Web::Services::Description::NamedItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class Port : System.Web.Services.Description.DocumentableItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class Port : System.Web.Services.Description.NamedItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type Port = class
    inherit DocumentableItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type Port = class
    inherit NamedItem
Public NotInheritable Class Port
Inherits DocumentableItem
Public NotInheritable Class Port
Inherits NamedItem
繼承
繼承
屬性

範例

下列範例會建立 , Port 並將其新增至 Ports 現有 ServiceDescription 具名 myDescription 的集合。

// Create a Port.
Port^ postPort = gcnew Port;
postPort->Name = "PortServiceHttpPost";
postPort->Binding = gcnew XmlQualifiedName( "s0:PortServiceHttpPost" );

// Create an HttpAddressBinding.
HttpAddressBinding^ postAddressBinding = gcnew HttpAddressBinding;
postAddressBinding->Location = "http://localhost/PortClass/PortService_cs.asmx";

// Add the HttpAddressBinding to the Port.
postPort->Extensions->Add( postAddressBinding );

// Get the Service of the postPort.
Service^ myService = postPort->Service;

// Print the service name for the port.
Console::WriteLine( "This is the service name of the postPort:*{0}*", myDescription->Services[ 0 ]->Ports[ 0 ]->Service->Name );

// Add the Port to the PortCollection of the ServiceDescription.
myDescription->Services[ 0 ]->Ports->Add( postPort );
// Create a Port.
Port postPort = new Port();
postPort.Name = "PortServiceHttpPost";
postPort.Binding = new XmlQualifiedName("s0:PortServiceHttpPost");

// Create an HttpAddressBinding.
HttpAddressBinding postAddressBinding = new HttpAddressBinding();
postAddressBinding.Location =
   "http://localhost/PortClass/PortService_cs.asmx";

// Add the HttpAddressBinding to the Port.
postPort.Extensions.Add(postAddressBinding);

// Get the Service of the postPort.
Service myService = postPort.Service;

// Print the service name for the port.
Console.WriteLine("This is the service name of the postPort:*" +
   myDescription.Services[0].Ports[0].Service.Name + "*");

// Add the Port to the PortCollection of the ServiceDescription.
myDescription.Services[0].Ports.Add(postPort);

' Create a Port.
Dim postPort As New Port()
postPort.Name = "PortServiceHttpPost"
postPort.Binding = New XmlQualifiedName("s0:PortServiceHttpPost")


' Create an HttpAddressBinding.
Dim postAddressBinding As New HttpAddressBinding()
postAddressBinding.Location = _
   "http://localhost/PortClass/PortService.vb.asmx"

' Add the HttpAddressBinding to the Port.
postPort.Extensions.Add(postAddressBinding)

' Get the Service of the postPort.
Dim myService As Service = postPort.Service

' Print the service name for the port.
Console.WriteLine("This is the service name of the postPort:*" & _
   myDescription.Services(0).Ports(0).Service.Name & "*")

' Add the Port to the PortCollection of the ServiceDescription.
myDescription.Services(0).Ports.Add(postPort)

備註

這個類別會針對 指定單一位址 (URI) Binding ,定義指定 PortType 之作業和訊息的訊息格式和通訊協定詳細資料。 屬性 Binding 會取得或設定指定 Port 之 的值。

這個類別會對應至 Web 服務描述語言 (WSDL) <port> 元素,此元素是由 <service> 元素所括住。 如需 WSDL 的詳細資訊,請參閱 WSDL 規格。

建構函式

Port()

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

屬性

Binding

取得或設定 Port 的 XML <binding> 屬性 (Attribute) 值。

Documentation

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

(繼承來源 DocumentableItem)
DocumentationElement

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

(繼承來源 DocumentableItem)
ExtensibleAttributes

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

(繼承來源 DocumentableItem)
Extensions

取得與 Port 相關聯擴充性項目的集合。

Name

取得或設定 Port 的名稱。

Name

取得或設定項目的名稱。

(繼承來源 NamedItem)
Namespaces

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

(繼承來源 DocumentableItem)
Service

取得 ServicePort 為其中的成員。

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱