ClientBase<TChannel> Class

 

Provides the base implementation used to create Windows Communication Foundation (WCF) client objects that can call services.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)


public abstract class ClientBase<TChannel> : ICommunicationObject, 
	IDisposable
where TChannel : class

Type Parameters

TChannel

The channel to be used to connect to the service.

NameDescription
System_CAPS_protmethodClientBase<TChannel>()

Initializes a new instance of the ClientBase<TChannel> class using the default target endpoint from the application configuration file.

System_CAPS_protmethodClientBase<TChannel>(Binding, EndpointAddress)

Initializes a new instance of the ClientBase<TChannel> class using the specified binding and target address.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext)

Initializes a new instance of the ClientBase<TChannel> class using the callbackInstance as the callback object in a duplex conversation.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

Initializes a new instance of the ClientBase<TChannel> class.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext, ServiceEndpoint)

Initializes a new instance of the ClientBase<TChannel> class using the specified InstanceContext and System.ServiceModel.Description.ServiceEndpoint objects.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext, String)

Initializes a new instance of the ClientBase<TChannel> class using the specified callback service and endpoint configuration information.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext, String, EndpointAddress)

Initializes a new instance of the ClientBase<TChannel> class.

System_CAPS_protmethodClientBase<TChannel>(InstanceContext, String, String)

Initializes a new instance of the ClientBase<TChannel> class.

System_CAPS_protmethodClientBase<TChannel>(ServiceEndpoint)

Initializes a new instance of the ClientBase<TChannel> class using the specified System.ServiceModel.Description.ServiceEndpoint.

System_CAPS_protmethodClientBase<TChannel>(String)

Initializes a new instance of the ClientBase<TChannel> class using the configuration information specified in the application configuration file by endpointConfigurationName.

System_CAPS_protmethodClientBase<TChannel>(String, EndpointAddress)

Initializes a new instance of the ClientBase<TChannel> class using the specified target address and endpoint information.

System_CAPS_protmethodClientBase<TChannel>(String, String)

Initializes a new instance of the ClientBase<TChannel> class.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticCacheSetting

Gets or sets the cache setting.

System_CAPS_protpropertyChannel

Gets the inner channel used to send messages to variously configured service endpoints.

System_CAPS_pubpropertyChannelFactory

Gets the underlying ChannelFactory<TChannel> object.

System_CAPS_pubpropertyClientCredentials

Gets the client credentials used to call an operation.

System_CAPS_pubpropertyEndpoint

Gets the target endpoint for the service to which the WCF client can connect.

System_CAPS_pubpropertyInnerChannel

Gets the underlying IClientChannel implementation.

System_CAPS_pubpropertyState

Gets the current state of the ClientBase<TChannel> object.

NameDescription
System_CAPS_pubmethodAbort()

Causes the ClientBase<TChannel> object to transition immediately from its current state into the closed state.

System_CAPS_pubmethodClose()

Causes the ClientBase<TChannel> object to transition from its current state into the closed state.

System_CAPS_protmethodCreateChannel()

Returns a new channel to the service.

System_CAPS_pubmethodDisplayInitializationUI()

Instructs the inner channel to display a user interface if one is required to initialize the channel prior to using it.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_protmethodGetDefaultValueForInitialization<T>()

Replicates the behavior of the default keyword in C#.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodInvokeAsync(ClientBase<TChannel>.BeginOperationDelegate, Object[], ClientBase<TChannel>.EndOperationDelegate, SendOrPostCallback, Object)

Provides support for implementing the event-based asynchronous pattern. For more information about this pattern, see Event-based Asynchronous Pattern Overview.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodOpen()

Causes the ClientBase<TChannel> object to transition from the created state into the opened state.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_priveventICommunicationObject.Closed

The event handler that is invoked when the ClientBase<TChannel> object has transitioned from its current state to the closed state.

System_CAPS_pubinterfaceSystem_CAPS_priveventICommunicationObject.Closing

The event handler that is invoked when the ClientBase<TChannel> object transitions from its current state to the closed state.

System_CAPS_pubinterfaceSystem_CAPS_priveventICommunicationObject.Faulted

The event handler that is invoked when a fault occurs while performing an operation on the ClientBase<TChannel> object.

System_CAPS_pubinterfaceSystem_CAPS_priveventICommunicationObject.Opened

The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state.

System_CAPS_pubinterfaceSystem_CAPS_priveventICommunicationObject.Opening

The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDisposable.Dispose()

Explicit implementation of the Dispose method.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.BeginClose(AsyncCallback, Object)

Begins an asynchronous operation to close the ClientBase<TChannel>.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object)

Begins an asynchronous operation to close the ClientBase<TChannel> with a specified timeout.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.BeginOpen(AsyncCallback, Object)

Begins an asynchronous operation to open the ClientBase<TChannel> object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object)

Begins an asynchronous operation to open the ClientBase<TChannel> object within a specified interval of time.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.Close(TimeSpan)

Causes the ClientBase<TChannel> object to transition from its current state into the closed state.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.EndClose(IAsyncResult)

Completes an asynchronous operation to close the ClientBase<TChannel> object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.EndOpen(IAsyncResult)

Completes an asynchronous operation to open the ClientBase<TChannel> object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICommunicationObject.Open(TimeSpan)

Causes the ClientBase<TChannel> object to transition from the created state into the opened state within a specified interval of time.

Extend the ClientBase<TChannel> class to create a custom WCF client object that can be used to connect to a service. Typically, the WCF client base class is extended by a tool such as the ServiceModel Metadata Utility Tool (Svcutil.exe) on your behalf. For an example, see the Example section.

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. 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.

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. For more information, seeWCF Client Overview and Accessing Services Using a WCF Client.

Special note for Managed C++ users deriving from this class:

  • Put your clean-up code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • Avoid destructors: they cause the compiler to auto-generate IDisposable.

  • Avoid non-reference members: they can cause the compiler to auto-generate IDisposable.

  • 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.

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);
    }
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: