locked
WCF Close Client for Each Call RRS feed

  • Question

  • Hello,

    We have a component that fetches data from a WCF Service. As the amount of data is huge the component is designed in such a way that the requests are chunked. This means multiple service calls would be required to complete the entire data flow transaction.

    The component uses a single service client instance and calls the service mutiple times (based on the chunks required).

    Is it a best practice to create a new client for each call, or reuse the service client with open and close for each call block?


    Regards, Dinesh

    Monday, August 20, 2012 3:41 PM

Answers

  • Reuse the same proxy especially when you use security features since the initial security negotiation can have high cost. Some of the best practices are mentioned here: http://blogs.msdn.com/b/wenlong/archive/2007/10/27/performance-improvement-of-wcf-client-proxy-creation-and-best-practices.aspx


    Lingaraj Mishra

    • Marked as answer by Dinesh Menon Monday, August 27, 2012 8:29 PM
    Tuesday, August 21, 2012 8:46 AM
  • Hello,

    We have a component that fetches data from a WCF Service. As the amount of data is huge the component is designed in such a way that the requests are chunked. This means multiple service calls would be required to complete the entire data flow transaction.

    The component uses a single service client instance and calls the service mutiple times (based on the chunks required).

    Is it a best practice to create a new client for each call, or reuse the service client with open and close for each call block?


    Regards, Dinesh

    I would keep the same instance and reuse it for each call. That said, I'm not sure exactly what your client is and why it needs to be closed after each call. I would leave it open, personally. Could you provide more information as to what exactly your "service client instance" is? This answer could possibly change depending on how your services are configured so I'm assuming a fairly simple/basic/standard configuration.

    • Marked as answer by Dinesh Menon Monday, August 27, 2012 8:29 PM
    Monday, August 20, 2012 4:20 PM

All replies

  • Hello,

    We have a component that fetches data from a WCF Service. As the amount of data is huge the component is designed in such a way that the requests are chunked. This means multiple service calls would be required to complete the entire data flow transaction.

    The component uses a single service client instance and calls the service mutiple times (based on the chunks required).

    Is it a best practice to create a new client for each call, or reuse the service client with open and close for each call block?


    Regards, Dinesh

    I would keep the same instance and reuse it for each call. That said, I'm not sure exactly what your client is and why it needs to be closed after each call. I would leave it open, personally. Could you provide more information as to what exactly your "service client instance" is? This answer could possibly change depending on how your services are configured so I'm assuming a fairly simple/basic/standard configuration.

    • Marked as answer by Dinesh Menon Monday, August 27, 2012 8:29 PM
    Monday, August 20, 2012 4:20 PM
  • Reuse the same proxy especially when you use security features since the initial security negotiation can have high cost. Some of the best practices are mentioned here: http://blogs.msdn.com/b/wenlong/archive/2007/10/27/performance-improvement-of-wcf-client-proxy-creation-and-best-practices.aspx


    Lingaraj Mishra

    • Marked as answer by Dinesh Menon Monday, August 27, 2012 8:29 PM
    Tuesday, August 21, 2012 8:46 AM
  • Thanks for the inputs. The WebURL helped a lot.

    Regards, Dinesh

    Monday, August 27, 2012 8:29 PM