ServiceHost.AddServiceEndpoint 方法

定義

將服務端點新增至裝載的服務。Adds a service endpoint to the hosted service.

多載

AddServiceEndpoint(Type, Binding, String)

使用指定的合約、繫結和端點位址,將服務端點加入至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.

AddServiceEndpoint(Type, Binding, Uri)

使用指定的合約、繫結以及含有端點位址的 URI,將服務端點新增至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, and URI that contains the endpoint address.

AddServiceEndpoint(Type, Binding, String, Uri)

使用指定的合約、繫結、端點位址以及服務所接聽的 URI,將服務端點加入至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, an endpoint address, and a URI on which the service listens.

AddServiceEndpoint(Type, Binding, Uri, Uri)

使用指定的合約、繫結、含有端點位址的 URI 以及服務所接聽的 URI,將服務端點新增至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, a URI that contains the endpoint address, and a URI on which the service listens.

AddServiceEndpoint(Type, Binding, String)

使用指定的合約、繫結和端點位址,將服務端點加入至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.

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

參數

implementedContract
Type

已加入之端點的合約 TypeThe Type of contract for the endpoint added.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
String

已加入之端點的位址。The address for the endpoint added.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address is null.

範例

WSHttpBinding binding = new WSHttpBinding();
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, "http://localhost:8000/servicemodelsamples/service/basic");
Dim binding As BasicHttpBinding = New BasicHttpBinding()
serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, "http://localhost:8000/servicemodelsamples/service/basic")

適用於

AddServiceEndpoint(Type, Binding, Uri)

使用指定的合約、繫結以及含有端點位址的 URI,將服務端點新增至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, and URI that contains the endpoint address.

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

參數

implementedContract
Type

已加入之端點的合約 TypeThe Type of contract for the endpoint added.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
Uri

Uri,其中包含已新增之端點的位址。The Uri that contains the address for the endpoint added.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address is null.

範例

BasicHttpBinding binding = new BasicHttpBinding();
Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/basic");
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);
Dim binding As BasicHttpBinding = New BasicHttpBinding()
Dim address As Uri = New Uri("http://localhost:8000/servicemodelsamples/service/basic")
serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address)

適用於

AddServiceEndpoint(Type, Binding, String, Uri)

使用指定的合約、繫結、端點位址以及服務所接聽的 URI,將服務端點加入至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, an endpoint address, and a URI on which the service listens.

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

參數

implementedContract
Type

已加入之端點的合約 TypeThe Type of contract for the endpoint added.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
String

服務的端點位址。The endpoint address for the service.

listenUri
Uri

服務端點可以接聽的 UriThe Uri on which the service endpoints can listen.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address is null.

範例

BasicHttpBinding binding = new BasicHttpBinding();
Uri listenUri = new Uri("http://localhost:8000/MyListenUri");
String address = "http://localhost:8000/servicemodelsamples/service2";
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address, listenUri);
Dim binding As BasicHttpBinding = New BasicHttpBinding()
Dim listenUri As Uri = New Uri("http://localhost:8000/MyListenUri")
Dim address As String = "http://localhost:8000/servicemodelsamples/service/basic"
serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address, listenUri)

備註

當您有多個必須接聽同一個指定之 URI 的端點時,可以使用這個版本的方法。Use this version of the method when you have multiple endpoints that need to listen on the same, specified URI.

適用於

AddServiceEndpoint(Type, Binding, Uri, Uri)

使用指定的合約、繫結、含有端點位址的 URI 以及服務所接聽的 URI,將服務端點新增至裝載的服務。Adds a service endpoint to the hosted service with a specified contract, binding, a URI that contains the endpoint address, and a URI on which the service listens.

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

參數

implementedContract
Type

已加入之端點的合約 TypeThe Type of contract for the endpoint added.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
Uri

Uri,其中包含已新增之端點的位址。The Uri that contains the address for the endpoint added.

listenUri
Uri

服務端點可以接聽的 UriThe Uri on which the service endpoints can listen.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address is null.

合約未初始化,或找不到合約索引鍵。The contracts are not initialized or the contract keys cannot be found.

範例

BasicHttpBinding binding = new BasicHttpBinding();
Uri listenUri = new Uri("http://localhost:8000/MyListenUri");
Uri address = new Uri("http://localhost:8000/servicemodelsamples/service3");
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address, listenUri);
Dim binding As BasicHttpBinding = New BasicHttpBinding()
Dim listenUri As Uri = New Uri("http://localhost:8000/MyListenUri")
Dim address As Uri = New Uri("http://localhost:8000/servicemodelsamples/service/basic")
serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, address, listenUri)

備註

當您有多個必須接聽同一個指定之 URI 的端點時,可以使用這個版本的方法。Use this version of the method when you have multiple endpoints that need to listen on the same, specified URI.

適用於