ClientBase<TChannel> Konstruktorer
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Initierar en ny instans av ClientBase<TChannel> klassen.
Överlagringar
| Name | Description |
|---|---|
| ClientBase<TChannel>() |
Initierar en ny instans av ClientBase<TChannel> klassen med standardmålslutpunkten från programkonfigurationsfilen. |
| ClientBase<TChannel>(InstanceContext, String, String) |
Initierar en ny instans av ClientBase<TChannel> klassen. |
| ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress) |
Initierar en ny instans av ClientBase<TChannel> klassen. |
| ClientBase<TChannel>(String, String) |
Initierar en ny instans av ClientBase<TChannel> klassen. |
| ClientBase<TChannel>(String, EndpointAddress) |
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna måladressen och slutpunktsinformationen. |
| ClientBase<TChannel>(InstanceContext, String) |
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> den angivna återanropstjänsten och konfigurationsinformationen för slutpunkten. |
| ClientBase<TChannel>(InstanceContext, String, EndpointAddress) |
Initierar en ny instans av ClientBase<TChannel> klassen. |
| ClientBase<TChannel>(Binding, EndpointAddress) |
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna bindningen och måladressen. |
| ClientBase<TChannel>(String) |
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> konfigurationsinformationen som anges i programkonfigurationsfilen av |
| ClientBase<TChannel>(InstanceContext) |
Initierar en ny instans av ClientBase<TChannel> klassen med som |
| ClientBase<TChannel>(ServiceEndpoint) |
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna ServiceEndpoint. |
| ClientBase<TChannel>(InstanceContext, ServiceEndpoint) |
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> angivna InstanceContext objekt och ServiceEndpoint objekt. |
Kommentarer
Använd för att skapa ett WCF-klientobjekt från slutpunktsinformationen i programkonfigurationsfilen. Konstruktorns huvudfunktion är att skapa en System.ServiceModel.ChannelFactory<TChannel> där typparametern är typen av måltjänstkontrakt.
ClientBase<TChannel>()
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
Initierar en ny instans av ClientBase<TChannel> klassen med standardmålslutpunkten från programkonfigurationsfilen.
protected:
ClientBase();
protected ClientBase();
Protected Sub New ()
Undantag
Antingen finns det ingen standardslutpunktsinformation i konfigurationsfilen, mer än en slutpunkt i filen eller ingen konfigurationsfil.
Exempel
Följande kodexempel visar hur en klient använder den här konstruktorn i en SampleServiceClient klass som utökar ClientBase<TChannel> klassen.
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
public class Client
{
public static void Main()
{
// Picks up configuration from the config file.
SampleServiceClient wcfClient = new SampleServiceClient();
try
{
// Making calls.
Console.WriteLine("Enter the greeting to send: ");
string greeting = Console.ReadLine();
Console.WriteLine("The service responded: " + wcfClient.SampleMethod(greeting));
Console.WriteLine("Press ENTER to exit:");
Console.ReadLine();
// Done with service.
wcfClient.Close();
Console.WriteLine("Done!");
}
catch (TimeoutException timeProblem)
{
Console.WriteLine("The service operation timed out. " + timeProblem.Message);
wcfClient.Abort();
Console.Read();
}
catch(CommunicationException commProblem)
{
Console.WriteLine("There was a communication problem. " + commProblem.Message);
wcfClient.Abort();
Console.Read();
}
}
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Public Class Client
Public Shared Sub Main()
' Picks up configuration from the config file.
Dim wcfClient As New SampleServiceClient()
Try
' Making calls.
Console.WriteLine("Enter the greeting to send: ")
Dim greeting = Console.ReadLine()
Console.WriteLine("The service responded: " & wcfClient.SampleMethod(greeting))
Console.WriteLine("Press ENTER to exit:")
Console.ReadLine()
' Done with service.
wcfClient.Close()
Console.WriteLine("Done!")
Catch timeProblem As TimeoutException
Console.WriteLine("The service operation timed out. " & timeProblem.Message)
wcfClient.Abort()
Console.Read()
Catch commProblem As CommunicationException
Console.WriteLine("There was a communication problem. " & commProblem.Message)
wcfClient.Abort()
Console.Read()
End Try
End Sub
End Class
Kommentarer
Använd den här konstruktorn för att skapa ett WCF-klientobjekt för att anropa en tjänst. Den här konstruktorn använder typparametern som målkontrakt och bindnings- och adressinformationen från programkonfigurationsfilen.
Gäller för
ClientBase<TChannel>(InstanceContext, String, String)
Initierar en ny instans av ClientBase<TChannel> klassen.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName, System::String ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String, remoteAddress As String)
Parametrar
- callbackInstance
- InstanceContext
Motringningsobjektet som klienten använder för att lyssna efter meddelanden från den anslutna tjänsten.
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
- remoteAddress
- String
Tjänstens adress.
Undantag
Motringningsinstansen, endpointConfigurationName, eller remoteAddress är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn för att skicka ett tjänstobjekt som implementerar återanropskontraktet för måltjänsten och fastställa målslutpunktsinformationen från namnet på slutpunkten i en programkonfigurationsfil (målvärdet finns genom att hitta name attributet för klientslutpunktselementet<>) och den angivna adressen.
Se även
Gäller för
ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
Initierar en ny instans av ClientBase<TChannel> klassen.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, binding As Binding, remoteAddress As EndpointAddress)
Parametrar
- callbackInstance
- InstanceContext
Återanropstjänsten.
- binding
- Binding
Bindningen som tjänsten ska anropas med.
- remoteAddress
- EndpointAddress
Adressen till tjänstslutpunkten.
Undantag
Motringningsinstansen, binding, eller remoteAddress är null.
Gäller för
ClientBase<TChannel>(String, String)
Initierar en ny instans av ClientBase<TChannel> klassen.
protected:
ClientBase(System::String ^ endpointConfigurationName, System::String ^ remoteAddress);
protected ClientBase(string endpointConfigurationName, string remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String, remoteAddress As String)
Parametrar
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
- remoteAddress
- String
Tjänstens adress.
Undantag
endpointConfigurationName eller remoteAddress är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn för att fastställa målslutpunktsinformationen från namnet på slutpunkten i en programkonfigurationsfil (målvärdet finns genom att hitta name attributet för klientslutpunktselementet<>) och den angivna adressen.
Se även
Gäller för
ClientBase<TChannel>(String, EndpointAddress)
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna måladressen och slutpunktsinformationen.
protected:
ClientBase(System::String ^ endpointConfigurationName, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String, remoteAddress As EndpointAddress)
Parametrar
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
- remoteAddress
- EndpointAddress
Tjänstens adress.
Undantag
endpointConfigurationName eller remoteAddress är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn för att fastställa målslutpunktsinformationen från namnet på slutpunkten i en programkonfigurationsfil (målvärdet finns genom att hitta name attributet för klientslutpunktselementet<>) och den angivna adressen.
Gäller för
ClientBase<TChannel>(InstanceContext, String)
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> den angivna återanropstjänsten och konfigurationsinformationen för slutpunkten.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String)
Parametrar
- callbackInstance
- InstanceContext
Motringningsobjektet som klienten använder för att lyssna efter meddelanden från den anslutna tjänsten.
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
Undantag
Motringningsinstansen eller endpointConfigurationName är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn för att skicka ett tjänstobjekt som implementerar återanropskontraktet för måltjänsten och fastställa målslutpunktsinformationen från klientprogrammets konfigurationsfil. Målvärdet finns genom att hitta name attributet för klientslutpunktselementet<>.
Gäller för
ClientBase<TChannel>(InstanceContext, String, EndpointAddress)
Initierar en ny instans av ClientBase<TChannel> klassen.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String, remoteAddress As EndpointAddress)
Parametrar
- callbackInstance
- InstanceContext
Motringningsobjektet som klienten använder för att lyssna efter meddelanden från den anslutna tjänsten.
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
- remoteAddress
- EndpointAddress
Tjänstens adress.
Undantag
Motringningsinstansen, endpointConfigurationName, eller remoteAddress är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn för att skicka ett tjänstobjekt som implementerar återanropskontraktet för måltjänsten och fastställa målslutpunktsinformationen från namnet på slutpunkten i en programkonfigurationsfil (målvärdet finns genom att hitta name attributet för klientslutpunktselementet<>) och den angivna adressen.
Se även
Gäller för
ClientBase<TChannel>(Binding, EndpointAddress)
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna bindningen och måladressen.
protected:
ClientBase(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (binding As Binding, remoteAddress As EndpointAddress)
Parametrar
- binding
- Binding
Bindningen som du vill göra anrop till tjänsten med.
- remoteAddress
- EndpointAddress
Adressen till tjänstslutpunkten.
Undantag
binding eller remoteAddress är null.
Gäller för
ClientBase<TChannel>(String)
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> konfigurationsinformationen som anges i programkonfigurationsfilen av endpointConfigurationName.
protected:
ClientBase(System::String ^ endpointConfigurationName);
protected ClientBase(string endpointConfigurationName);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String)
Parametrar
- endpointConfigurationName
- String
Namnet på slutpunkten i programkonfigurationsfilen.
Undantag
Den angivna slutpunktsinformationen är null.
Det går inte att hitta slutpunkten eller så är slutpunktskontraktet ogiltigt.
Kommentarer
Använd den här konstruktorn när det finns mer än en målslutpunkt i programkonfigurationsfilen. Det här värdet är name attributet för klientslutpunktselementet<>.
Gäller för
ClientBase<TChannel>(InstanceContext)
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
Initierar en ny instans av ClientBase<TChannel> klassen med som callbackInstance motringningsobjekt i en duplex-konversation.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext)
Parametrar
- callbackInstance
- InstanceContext
Motringningsobjektet som klientprogrammet använder för att lyssna efter meddelanden från den anslutna tjänsten.
Undantag
Motringningsinstansen är null.
Antingen finns det ingen standardslutpunktsinformation i konfigurationsfilen, mer än en slutpunkt i filen eller ingen konfigurationsfil.
Exempel
Följande kodexempel visar hur du använder den här konstruktorn med en SampleDuplexHelloClient klass för att skicka ett motringningsobjekt som lyssnar efter meddelanden från tjänsten.
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;
namespace Microsoft.WCF.Documentation
{
[CallbackBehaviorAttribute(
IncludeExceptionDetailInFaults= true,
UseSynchronizationContext=true,
ValidateMustUnderstand=true
)]
public class Client : SampleDuplexHelloCallback
{
AutoResetEvent waitHandle;
public Client()
{
waitHandle = new AutoResetEvent(false);
}
public void Run()
{
// Picks up configuration from the configuration file.
SampleDuplexHelloClient wcfClient
= new SampleDuplexHelloClient(new InstanceContext(this), "WSDualHttpBinding_SampleDuplexHello");
try
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Enter a greeting to send and press ENTER: ");
Console.Write(">>> ");
Console.ForegroundColor = ConsoleColor.Green;
string greeting = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Called service with: \r\n\t" + greeting);
wcfClient.Hello(greeting);
Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
this.waitHandle.WaitOne();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Set was called.");
Console.Write("Press ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("ENTER");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write(" to exit...");
Console.ReadLine();
}
catch (TimeoutException timeProblem)
{
Console.WriteLine("The service operation timed out. " + timeProblem.Message);
Console.ReadLine();
}
catch (CommunicationException commProblem)
{
Console.WriteLine("There was a communication problem. " + commProblem.Message);
Console.ReadLine();
}
}
public static void Main()
{
Client client = new Client();
client.Run();
}
public void Reply(string response)
{
Console.WriteLine("Received output.");
Console.WriteLine("\r\n\t" + response);
this.waitHandle.Set();
}
}
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Threading
Namespace Microsoft.WCF.Documentation
<CallbackBehaviorAttribute(IncludeExceptionDetailInFaults:= True, UseSynchronizationContext:=True, ValidateMustUnderstand:=True)> _
Public Class Client
Implements SampleDuplexHelloCallback
Private waitHandle As AutoResetEvent
Public Sub New()
waitHandle = New AutoResetEvent(False)
End Sub
Public Sub Run()
' Picks up configuration from the configuration file.
Dim wcfClient As New SampleDuplexHelloClient(New InstanceContext(Me), "WSDualHttpBinding_SampleDuplexHello")
Try
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Enter a greeting to send and press ENTER: ")
Console.Write(">>> ")
Console.ForegroundColor = ConsoleColor.Green
Dim greeting As String = Console.ReadLine()
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Called service with: " & Constants.vbCrLf & Constants.vbTab & greeting)
wcfClient.Hello(greeting)
Console.WriteLine("Execution passes service call and moves to the WaitHandle.")
Me.waitHandle.WaitOne()
Console.ForegroundColor = ConsoleColor.Blue
Console.WriteLine("Set was called.")
Console.Write("Press ")
Console.ForegroundColor = ConsoleColor.Red
Console.Write("ENTER")
Console.ForegroundColor = ConsoleColor.Blue
Console.Write(" to exit...")
Console.ReadLine()
Catch timeProblem As TimeoutException
Console.WriteLine("The service operation timed out. " & timeProblem.Message)
Console.ReadLine()
Catch commProblem As CommunicationException
Console.WriteLine("There was a communication problem. " & commProblem.Message)
Console.ReadLine()
End Try
End Sub
Public Shared Sub Main()
Dim client As New Client()
client.Run()
End Sub
Public Sub Reply(ByVal response As String) Implements SampleDuplexHelloCallback.Reply
Console.WriteLine("Received output.")
Console.WriteLine(Constants.vbCrLf & Constants.vbTab & response)
Me.waitHandle.Set()
End Sub
End Class
End Namespace
Kommentarer
Använd den här konstruktorn när tjänstkontraktet kräver en instans av återanropstjänsten. Målslutpunkten skapas utifrån typparametern och informationen i programkonfigurationsfilen.
Se även
Gäller för
ClientBase<TChannel>(ServiceEndpoint)
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
- Källa:
- ClientBase.cs
Initierar en ny instans av ClientBase<TChannel> klassen med den angivna ServiceEndpoint.
protected:
ClientBase(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
protected ClientBase(System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpoint As ServiceEndpoint)
Parametrar
- endpoint
- ServiceEndpoint
Slutpunkten för en tjänst som gör det möjligt för klienter att hitta och kommunicera med tjänsten.
Gäller för
ClientBase<TChannel>(InstanceContext, ServiceEndpoint)
Initierar en ny instans av klassen med hjälp av ClientBase<TChannel> angivna InstanceContext objekt och ServiceEndpoint objekt.
protected:
ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpoint As ServiceEndpoint)
Parametrar
- callbackInstance
- InstanceContext
Motringningsobjektet som klientprogrammet använder för att lyssna efter meddelanden från den anslutna tjänsten.
- endpoint
- ServiceEndpoint
Slutpunkten för en tjänst som gör det möjligt för klienter att hitta och kommunicera med tjänsten.