ClientBase<TChannel> ClientBase<TChannel> ClientBase<TChannel> ClientBase<TChannel> Class

Definición

Proporciona la implementación base usada para crear objetos de cliente Windows Communication Foundation (WCF) que pueden llamar a los servicios.Provides the base implementation used to create Windows Communication Foundation (WCF) client objects that can call services.

generic <typename TChannel>
 where TChannel : classpublic ref class ClientBase abstract : IDisposable, System::ServiceModel::ICommunicationObject
public abstract class ClientBase<TChannel> : IDisposable, System.ServiceModel.ICommunicationObject where TChannel : class
type ClientBase<'Channel (requires 'Channel : null)> = class
    interface IDisposable
    interface ICommunicationObject
Public MustInherit Class ClientBase(Of TChannel)
Implements ICommunicationObject, IDisposable

Parámetros de tipo

TChannel

El canal que se va a utilizar para conectarse al servicio.The channel to be used to connect to the service.

Herencia
ClientBase<TChannel>ClientBase<TChannel>ClientBase<TChannel>ClientBase<TChannel>
Derivado
Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestra cómo la herramienta de utilidad de metadatos de ServiceModel (SvcUtil. exe) amplía la ClientBase<TChannel> clase para crear una clase de cliente de WCF.The following code example shows how the ServiceModel Metadata Utility Tool (Svcutil.exe) extends the ClientBase<TChannel> class to create a WCF client class.

public partial class SampleServiceClient : System.ServiceModel.ClientBase<ISampleService>, ISampleService
{
    
    public SampleServiceClient()
    {
    }
    
    public SampleServiceClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }
    
    public SampleServiceClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }
    
    public SampleServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }
    
    public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }
    
    public string SampleMethod(string msg)
    {
        return base.Channel.SampleMethod(msg);
    }
}
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class SampleServiceClient
    Inherits System.ServiceModel.ClientBase(Of ISampleService)
    Implements ISampleService

    Public Sub New()
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String)
        MyBase.New(endpointConfigurationName)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, _
                   ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, _
                   ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(binding, remoteAddress)
    End Sub

    Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
        Return MyBase.Channel.SampleMethod(msg)
    End Function
End Class

Comentarios

Extienda la ClientBase<TChannel> clase para crear un objeto de cliente de WCF personalizado que se pueda usar para conectarse a un servicio.Extend the ClientBase<TChannel> class to create a custom WCF client object that can be used to connect to a service. Normalmente, la clase base de cliente de WCF se extiende mediante una herramienta como la herramienta de utilidad de metadatos de ServiceModel (SvcUtil. exe) en su nombre.Typically, the WCF client base class is extended by a tool such as the ServiceModel Metadata Utility Tool (Svcutil.exe) on your behalf. Para obtener un ejemplo, vea la sección Ejemplo.For an example, see the Example section.

Los programadores que prefieren los objetos al uso de las interfaces y la clase ClientBase<TChannel> pueden utilizar rápidamente y con facilidad la clase System.ServiceModel.ChannelFactory<TChannel>.The ClientBase<TChannel> class can be used quickly and easily by developers who prefer objects to the use of the interfaces and the System.ServiceModel.ChannelFactory<TChannel> class. En todos los casos, esta clase encapsula o expone los métodos y la funcionalidad de la clase System.ServiceModel.ChannelFactory<TChannel> y de la interfaz System.ServiceModel.IClientChannel.In all cases this class wraps or exposes the methods and functionality of the System.ServiceModel.ChannelFactory<TChannel> class and the System.ServiceModel.IClientChannel interface.

Como al utilizar la clase System.ServiceModel.ServiceHost, puede crear la clase y modificar el punto de conexión, el generador de canales o la información de seguridad antes de realizar llamadas o llamar a Open.As when using the System.ServiceModel.ServiceHost class, you can create the class and modify the endpoint, channel factory, or security information prior to making any calls or calling Open. Para obtener más información, consulte información general del cliente de WCF y acceso a servicios mediante un cliente WCF.For more information, see WCF Client Overview and Accessing Services Using a WCF Client.

Nota especial para los usuarios de C++ que deriven de esta clase:Special note for Managed C++ users deriving from this class:

  • Coloque su código de limpieza en (On)(Begin)Close (y/o OnAbort), no en un destructor.Put your clean-up code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • Evite los destructores: hacen que el compilador genere automáticamente IDisposableAvoid destructors: they cause the compiler to auto-generate IDisposable.

  • Evite los miembros sin referencia: pueden hacer que el compilador genere automáticamente IDisposable.Avoid non-reference members: they can cause the compiler to auto-generate IDisposable.

  • Evite los finalizadores; pero si incluye uno, debería suprimir la advertencia de creación y llamar a SuppressFinalize(Object) y al propio finalizador de (On)(Begin)Close (y/o OnAbort) para emular lo que habría sido el comportamiento de IDisposable generado automáticamente.Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize(Object) and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated IDisposable behavior.

Constructores

ClientBase<TChannel>() ClientBase<TChannel>() ClientBase<TChannel>() ClientBase<TChannel>()

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando el extremo de destino predeterminado del archivo de configuración de aplicación.Initializes a new instance of the ClientBase<TChannel> class using the default target endpoint from the application configuration file.

ClientBase<TChannel>(Binding, EndpointAddress) ClientBase<TChannel>(Binding, EndpointAddress) ClientBase<TChannel>(Binding, EndpointAddress) ClientBase<TChannel>(Binding, EndpointAddress)

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando la dirección de enlace y de destino especificada.Initializes a new instance of the ClientBase<TChannel> class using the specified binding and target address.

ClientBase<TChannel>(InstanceContext) ClientBase<TChannel>(InstanceContext) ClientBase<TChannel>(InstanceContext) ClientBase<TChannel>(InstanceContext)

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando callbackInstance como objeto de devolución de llamada en una conversación dúplex.Initializes a new instance of the ClientBase<TChannel> class using the callbackInstance as the callback object in a duplex conversation.

ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress) ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress) ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress) ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

Inicializa una nueva instancia de la clase ClientBase<TChannel>.Initializes a new instance of the ClientBase<TChannel> class.

ClientBase<TChannel>(InstanceContext, ServiceEndpoint) ClientBase<TChannel>(InstanceContext, ServiceEndpoint) ClientBase<TChannel>(InstanceContext, ServiceEndpoint) ClientBase<TChannel>(InstanceContext, ServiceEndpoint)

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando los objetos InstanceContext y ServiceEndpoint especificados.Initializes a new instance of the ClientBase<TChannel> class using the specified InstanceContext and ServiceEndpoint objects.

ClientBase<TChannel>(InstanceContext, String) ClientBase<TChannel>(InstanceContext, String) ClientBase<TChannel>(InstanceContext, String) ClientBase<TChannel>(InstanceContext, String)

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando el servicio de devolución de llamada especificado y la información de configuración del extremo.Initializes a new instance of the ClientBase<TChannel> class using the specified callback service and endpoint configuration information.

ClientBase<TChannel>(InstanceContext, String, EndpointAddress) ClientBase<TChannel>(InstanceContext, String, EndpointAddress) ClientBase<TChannel>(InstanceContext, String, EndpointAddress) ClientBase<TChannel>(InstanceContext, String, EndpointAddress)

Inicializa una nueva instancia de la clase ClientBase<TChannel>.Initializes a new instance of the ClientBase<TChannel> class.

ClientBase<TChannel>(InstanceContext, String, String) ClientBase<TChannel>(InstanceContext, String, String) ClientBase<TChannel>(InstanceContext, String, String) ClientBase<TChannel>(InstanceContext, String, String)

Inicializa una nueva instancia de la clase ClientBase<TChannel>.Initializes a new instance of the ClientBase<TChannel> class.

ClientBase<TChannel>(ServiceEndpoint) ClientBase<TChannel>(ServiceEndpoint) ClientBase<TChannel>(ServiceEndpoint) ClientBase<TChannel>(ServiceEndpoint)

Inicializa una nueva instancia de la clase ClientBase<TChannel> usando la clase ServiceEndpoint especificada.Initializes a new instance of the ClientBase<TChannel> class using the specified ServiceEndpoint.

ClientBase<TChannel>(String) ClientBase<TChannel>(String) ClientBase<TChannel>(String) ClientBase<TChannel>(String)

Inicializa una nueva instancia de la clase ClientBase<TChannel> utilizando la información de configuración especificada por endpointConfigurationName en el archivo de configuración de aplicación.Initializes a new instance of the ClientBase<TChannel> class using the configuration information specified in the application configuration file by endpointConfigurationName.

ClientBase<TChannel>(String, EndpointAddress) ClientBase<TChannel>(String, EndpointAddress) ClientBase<TChannel>(String, EndpointAddress) ClientBase<TChannel>(String, EndpointAddress)

Inicializa una nueva instancia de la clase ClientBase<TChannel> con la dirección de destino e información de extremo especificadas.Initializes a new instance of the ClientBase<TChannel> class using the specified target address and endpoint information.

ClientBase<TChannel>(String, String) ClientBase<TChannel>(String, String) ClientBase<TChannel>(String, String) ClientBase<TChannel>(String, String)

Inicializa una nueva instancia de la clase ClientBase<TChannel>.Initializes a new instance of the ClientBase<TChannel> class.

Propiedades

CacheSetting CacheSetting CacheSetting CacheSetting

Obtiene o establece la configuración de la memoria caché.Gets or sets the cache setting.

Channel Channel Channel Channel

Obtiene el canal interno utilizado para enviar mensajes a extremos de servicio configurados de distinta manera.Gets the inner channel used to send messages to variously configured service endpoints.

ChannelFactory ChannelFactory ChannelFactory ChannelFactory

Obtiene el objeto ChannelFactory<TChannel> subyacente.Gets the underlying ChannelFactory<TChannel> object.

ClientCredentials ClientCredentials ClientCredentials ClientCredentials

Obtiene las credenciales de cliente utilizadas para llamar a una operación.Gets the client credentials used to call an operation.

Endpoint Endpoint Endpoint Endpoint

Obtiene el punto de conexión de destino para el servicio al que puede conectarse el cliente WCF.Gets the target endpoint for the service to which the WCF client can connect.

InnerChannel InnerChannel InnerChannel InnerChannel

Obtiene la implementación IClientChannel subyacente.Gets the underlying IClientChannel implementation.

State State State State

Obtiene el estado actual del objeto ClientBase<TChannel>.Gets the current state of the ClientBase<TChannel> object.

Métodos

Abort() Abort() Abort() Abort()

Provoca que el objeto ClientBase<TChannel> pase inmediatamente de su estado actual al estado cerrado.Causes the ClientBase<TChannel> object to transition immediately from its current state into the closed state.

Close() Close() Close() Close()

Provoca que el objeto ClientBase<TChannel> pase de su estado actual al estado cerrado.Causes the ClientBase<TChannel> object to transition from its current state into the closed state.

CreateChannel() CreateChannel() CreateChannel() CreateChannel()

Devuelve un canal nuevo al servicio.Returns a new channel to the service.

DisplayInitializationUI() DisplayInitializationUI() DisplayInitializationUI() DisplayInitializationUI()

Indica al canal interno que muestre una interfaz de usuario si se necesita para inicializar el canal antes de utilizarlo.Instructs the inner channel to display a user interface if one is required to initialize the channel prior to using it.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDefaultValueForInitialization<T>() GetDefaultValueForInitialization<T>() GetDefaultValueForInitialization<T>() GetDefaultValueForInitialization<T>()

Replica el comportamiento de la palabra clave predeterminada en C#.Replicates the behavior of the default keyword in C#.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
InvokeAsync(ClientBase<TChannel>, Object[], ClientBase<TChannel>, SendOrPostCallback, Object) InvokeAsync(ClientBase<TChannel>, Object[], ClientBase<TChannel>, SendOrPostCallback, Object) InvokeAsync(ClientBase<TChannel>, Object[], ClientBase<TChannel>, SendOrPostCallback, Object) InvokeAsync(ClientBase<TChannel>, Object[], ClientBase<TChannel>, SendOrPostCallback, Object)

Proporciona compatibilidad para implementar el modelo asincrónico basado en eventos.Provides support for implementing the event-based asynchronous pattern. Para más información sobre este patrón, consulte Información general sobre el modelo asincrónico basado en eventos.For more information about this pattern, see Event-based Asynchronous Pattern Overview.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
Open() Open() Open() Open()

Provoca que el objeto ClientBase<TChannel> pase desde el estado creado al estado abierto.Causes the ClientBase<TChannel> object to transition from the created state into the opened state.

ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

ICommunicationObject.BeginClose(AsyncCallback, Object) ICommunicationObject.BeginClose(AsyncCallback, Object) ICommunicationObject.BeginClose(AsyncCallback, Object) ICommunicationObject.BeginClose(AsyncCallback, Object)

Comienza una operación asincrónica para cerrar ClientBase<TChannel>.Begins an asynchronous operation to close the ClientBase<TChannel>.

ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object)

Comienza una operación asincrónica para cerrar ClientBase<TChannel> con un tiempo de espera especificado.Begins an asynchronous operation to close the ClientBase<TChannel> with a specified timeout.

ICommunicationObject.BeginOpen(AsyncCallback, Object) ICommunicationObject.BeginOpen(AsyncCallback, Object) ICommunicationObject.BeginOpen(AsyncCallback, Object) ICommunicationObject.BeginOpen(AsyncCallback, Object)

Comienza una operación asincrónica para abrir el objeto ClientBase<TChannel>.Begins an asynchronous operation to open the ClientBase<TChannel> object.

ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object) ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object)

Comienza una operación asincrónica para abrir el objeto ClientBase<TChannel> dentro de un intervalo de tiempo especificado.Begins an asynchronous operation to open the ClientBase<TChannel> object within a specified interval of time.

ICommunicationObject.Close() ICommunicationObject.Close() ICommunicationObject.Close() ICommunicationObject.Close()
ICommunicationObject.Close(TimeSpan) ICommunicationObject.Close(TimeSpan) ICommunicationObject.Close(TimeSpan) ICommunicationObject.Close(TimeSpan)

Provoca que el objeto ClientBase<TChannel> pase de su estado actual al estado cerrado.Causes the ClientBase<TChannel> object to transition from its current state into the closed state.

ICommunicationObject.Closed ICommunicationObject.Closed ICommunicationObject.Closed ICommunicationObject.Closed

El controlador de eventos que se invoca cuando el objeto ClientBase<TChannel> ha pasado desde su estado actual al estado cerrado.The event handler that is invoked when the ClientBase<TChannel> object has transitioned from its current state to the closed state.

ICommunicationObject.Closing ICommunicationObject.Closing ICommunicationObject.Closing ICommunicationObject.Closing

El controlador de eventos que se invoca cuando el objeto ClientBase<TChannel> pasa desde su estado actual al estado cerrado.The event handler that is invoked when the ClientBase<TChannel> object transitions from its current state to the closed state.

ICommunicationObject.EndClose(IAsyncResult) ICommunicationObject.EndClose(IAsyncResult) ICommunicationObject.EndClose(IAsyncResult) ICommunicationObject.EndClose(IAsyncResult)

Completa una operación asincrónica para cerrar el objeto ClientBase<TChannel>.Completes an asynchronous operation to close the ClientBase<TChannel> object.

ICommunicationObject.EndOpen(IAsyncResult) ICommunicationObject.EndOpen(IAsyncResult) ICommunicationObject.EndOpen(IAsyncResult) ICommunicationObject.EndOpen(IAsyncResult)

Completa una operación asincrónica para abrir el objeto ClientBase<TChannel>.Completes an asynchronous operation to open the ClientBase<TChannel> object.

ICommunicationObject.Faulted ICommunicationObject.Faulted ICommunicationObject.Faulted ICommunicationObject.Faulted

El controlador de eventos que se invoca cuando se produce un error mientras se realiza una operación en el objeto ClientBase<TChannel>.The event handler that is invoked when a fault occurs while performing an operation on the ClientBase<TChannel> object.

ICommunicationObject.Open() ICommunicationObject.Open() ICommunicationObject.Open() ICommunicationObject.Open()
ICommunicationObject.Open(TimeSpan) ICommunicationObject.Open(TimeSpan) ICommunicationObject.Open(TimeSpan) ICommunicationObject.Open(TimeSpan)

Provoca que el objeto ClientBase<TChannel> pase del estado creado al estado abierto dentro de un intervalo de tiempo especificado.Causes the ClientBase<TChannel> object to transition from the created state into the opened state within a specified interval of time.

ICommunicationObject.Opened ICommunicationObject.Opened ICommunicationObject.Opened ICommunicationObject.Opened

El controlador de eventos que se invoca cuando el objeto ClientBase<TChannel> pasa desde el estado creado al estado abierto.The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state.

ICommunicationObject.Opening ICommunicationObject.Opening ICommunicationObject.Opening ICommunicationObject.Opening

El controlador de eventos que se invoca cuando el objeto ClientBase<TChannel> pasa desde el estado creado al estado abierto.The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state.

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

Implementación explícita del método Dispose().Explicit implementation of the Dispose() method.

Se aplica a