How to correctly open WCF service

Posted by Sergej Andrejev on Stack Overflow See other posts from Stack Overflow or by Sergej Andrejev
Published on 2010-01-25T14:55:37Z Indexed on 2010/03/27 20:03 UTC
Read the original article Hit count: 264

Filed under:

Hi there,

I'm using WCF client like this...

var client = new TestClient();
try
{    
    response = service.Operation(request);
}
finally
{    
    try
    {
        if (client.State != CommunicationState.Faulted)
            client.Close();
    }
    catch (Exception)
    {
        client.Abort();
    }
}

but from time to time I get 500 HTTP error which is the only answer I get for next 15 minutes, then everything is back to normal for 15 minutes and so on. I know there is some load balancing stuff going on service side but guys there can't find any problems with it.

That's why I started wondering am I using WCF service correctly. I already made a mistake once when I was using "using" to close service connection and I'm afraid I doing something wrong again.

So can anybody say whether my way of calling WCF service is correct or not in all (event the most rare) circumstances?

© Stack Overflow or respective owner

Related posts about wcf