ServiceHostBase.AddServiceEndpoint 方法

定義

將服務端點新增至裝載的服務。

多載

AddServiceEndpoint(ServiceEndpoint)

將指定的服務端點加入至裝載的服務。

AddServiceEndpoint(String, Binding, String)

使用指定的合約、繫結和端點位址,將服務端點加入至裝載的服務。

AddServiceEndpoint(String, Binding, Uri)

使用指定的合約、繫結以及含有端點位址的 URI,將服務端點新增至裝載的服務。

AddServiceEndpoint(String, Binding, String, Uri)

使用指定的合約、繫結、端點位址,以及包含其接聽所在位址的 URI,將服務端點新增至裝載的服務。

AddServiceEndpoint(String, Binding, Uri, Uri)

使用指定的合約、繫結以及含有端點與接聽位址的 URI,將服務端點新增至裝載的服務。

AddServiceEndpoint(ServiceEndpoint)

將指定的服務端點加入至裝載的服務。

public:
 virtual void AddServiceEndpoint(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
public virtual void AddServiceEndpoint (System.ServiceModel.Description.ServiceEndpoint endpoint);
abstract member AddServiceEndpoint : System.ServiceModel.Description.ServiceEndpoint -> unit
override this.AddServiceEndpoint : System.ServiceModel.Description.ServiceEndpoint -> unit
Public Overridable Sub AddServiceEndpoint (endpoint As ServiceEndpoint)

參數

endpoint
ServiceEndpoint

服務端點。

例外狀況

Endpointnull

主機的狀態並不是已建立或開啟中,或是裝載之服務沒有任何 ServiceDescription

AddressBindingContract 屬性為 null

備註

使用 方法時,服務主機會在合約描述上執行「by-configuration-name」驗證。 換句話說,主機會 ConfigurationName 確認存在於服務所實作之服務合約的組態名稱清單中。 如果通過驗證,則會依原樣使用 中的 ServiceEndpoint 描述,即使 ContractDescription 從服務反映的 是不同的。

例如,假設 ServiceEndpoint 中的描述和從服務反映的合約描述具有相同的名稱,但不同的作業行為。 只有「by-configuration-name」 驗證的含意在於沒有行為相同的驗證,而且因為另一個描述而有一個描述的更新。

address如果 是相對 URI, (的其中一個基底位址 ServiceHost ,視系結通訊協定) 作為端點的基底位址使用。

適用於

AddServiceEndpoint(String, Binding, String)

使用指定的合約、繫結和端點位址,將服務端點加入至裝載的服務。

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, System::String ^ address);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, string address);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * string -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As String) As ServiceEndpoint

參數

implementedContract
String

由端點實作的合約。

binding
Binding

已新增之端點的 Binding

address
String

已加入之端點的位址。 這個位址可以是絕對或相對 URI。 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。

傳回

已新增至裝載之服務的 ServiceEndpoint

例外狀況

implementedContractbindingaddressnull

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點或繫結缺少繫結配置傳輸。

範例

  NetTcpBinding portsharingBinding = new NetTcpBinding();
  hostDefault.AddServiceEndpoint(
typeof(CalculatorService),
portsharingBinding,
"net.tcp://localhost/MyService");

適用於

AddServiceEndpoint(String, Binding, Uri)

使用指定的合約、繫結以及含有端點位址的 URI,將服務端點新增至裝載的服務。

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, Uri ^ address);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, Uri address);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As Uri) As ServiceEndpoint

參數

implementedContract
String

由端點實作的合約。

binding
Binding

已新增之端點的 Binding

address
Uri

Uri,其中包含已新增之端點的位址。 這個位址可以是絕對或相對 URI。 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。

傳回

已新增至裝載之服務的 ServiceEndpoint

例外狀況

implementedContractbindingaddressnull

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。

適用於

AddServiceEndpoint(String, Binding, String, Uri)

使用指定的合約、繫結、端點位址,以及包含其接聽所在位址的 URI,將服務端點新增至裝載的服務。

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, System::String ^ address, Uri ^ listenUri);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, string address, Uri listenUri);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * string * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As String, listenUri As Uri) As ServiceEndpoint

參數

implementedContract
String

由端點實作的合約。

binding
Binding

已新增之端點的 Binding

address
String

已加入之端點的位址。 這個位址可以是絕對或相對 URI。 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。

listenUri
Uri

Uri,其中包含端點接聽傳入訊息的所在位址。 這裡可以使用相對或絕對的 URI。

傳回

已新增至裝載之服務的 ServiceEndpoint

例外狀況

implementedContractbindingaddressnull

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。

備註

address如果 是相對 URI, (的其中一個基底位址 ServiceHost ,視系結通訊協定) 作為端點的基底位址使用。

適用於

AddServiceEndpoint(String, Binding, Uri, Uri)

使用指定的合約、繫結以及含有端點與接聽位址的 URI,將服務端點新增至裝載的服務。

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, Uri ^ address, Uri ^ listenUri);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, Uri address, Uri listenUri);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * Uri * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As Uri, listenUri As Uri) As ServiceEndpoint

參數

implementedContract
String

由端點實作的合約。

binding
Binding

已新增之端點的 Binding

address
Uri

Uri,其中包含已新增之端點的位址。 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。

listenUri
Uri

Uri,其中包含端點接聽傳入訊息的所在位址。

傳回

已新增至裝載之服務的 ServiceEndpoint。 這裡可以使用絕對或相對的 URI。

例外狀況

implementedContractbindingaddressnull

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。

適用於