ServiceHost.AddServiceEndpoint 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為託管服務新增服務端點。
多載
| 名稱 | Description |
|---|---|
| AddServiceEndpoint(Type, Binding, String) |
將服務端點加入託管服務,並指定合約、綁定及端點位址。 |
| AddServiceEndpoint(Type, Binding, Uri) |
將服務端點加入受控服務,並附有指定的合約、綁定及包含端點位址的 URI。 |
| AddServiceEndpoint(Type, Binding, String, Uri) |
在託管服務中加入一個服務端點,並附上指定的合約、綁定、端點位址,以及服務會監聽的 URI。 |
| AddServiceEndpoint(Type, Binding, Uri, Uri) |
在託管服務中新增一個服務端點,並附有指定的合約、綁定、包含端點位址的 URI,以及服務監聽的 URI。 |
AddServiceEndpoint(Type, Binding, String)
將服務端點加入託管服務,並指定合約、綁定及端點位址。
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
參數
- address
- String
補充了端點的地址。
傳回
他們 ServiceEndpoint 加入了託管服務。
例外狀況
implementedContract或bindingaddress是 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。
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
參數
傳回
他們 ServiceEndpoint 加入了託管服務。
例外狀況
implementedContract或bindingaddress是 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。
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
參數
- address
- String
服務的端點位址。
傳回
他們 ServiceEndpoint 加入了託管服務。
例外狀況
implementedContract或bindingaddress是 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 時,可以使用這個版本的方法。
適用於
AddServiceEndpoint(Type, Binding, Uri, Uri)
在託管服務中新增一個服務端點,並附有指定的合約、綁定、包含端點位址的 URI,以及服務監聽的 URI。
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
參數
傳回
他們 ServiceEndpoint 加入了託管服務。
例外狀況
implementedContract或bindingaddress是 null。
合約未被初始化,或找不到合約金鑰。
範例
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 時,可以使用這個版本的方法。