I have a wrapper around a WCF service APIs
Class APIWrapper
{
private WCFClient _client;
//constructor opens a client connection
public APIWrapper()
{
_client = new WCFClient();
_client.open();
}
public API1()
{
_client.doSomething1();
}
public API2()
{
_client.doSomething2();
}
}
I want to ask:
Q1 will timeout exception occur? if this wrapper class instance exists for too long? (does the WCF connection by default keepalive? without setting that attribute in config) for example, after a wrapper class is constructed, its API1 or API2 is called after 10mins, which is longer than the timeout value of this WCF connection.
Q2 Do I need explicitly close the connection, if so, should I do it in the destructor of the wrapper class like below?
~APIWrapper
{
if(_client !=null)
try{
_client.close(); }
catch(Exception e){
_client.Abort(); }
}