Solved

Necessary or optional to close a webservice client connection

Posted on 2012-03-13
3
272 Views
Last Modified: 2012-03-14
If I have created a web service client that makes a call to a method exposed by a web service, do I need to perform some sort of close when I am finished using the object?

  ConsoleApplicationTomTest.ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client();

            string a = sc.GetData(1);

            Console.WriteLine(a);

            Console.ReadLine();

///////////  sc.CloseClientConnection(  )   ??????????
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 37718100
Short answer - yes.

If you access the URL for the service in the browser and read the sample there (xml-ws) or follow the instructions for creating a client code block from the wsdl (wcf) you will see the example does indeed close the connection.

if you don't you'll rapidly find that the timeout interval of the client connection at the server side prevents the automatic disposal of the connection in time to free up enough connections and you will hit the limit (partially stipulated by your xmlws/wcf configuration file) and start receiving error messages about connection limits.

Try instantiating a few hundred instances of your connection/test method call and you will see what I mean - always be lean, create as few instances as possible and dispose of them properly and promptly. This goes for all instances of classes not just wcf/xml-ws clients.
0
 
LVL 9

Expert Comment

by:lojk
ID: 37718144
Return cross posted link to related question FYI :-)

http://www.experts-exchange.com/Programming/Languages/.NET/Q_27630729.html
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 37720329
Thank you.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I do Unit Testing with Session ? 1 41
PowerShell: ForEach-Object Export to CSV 4 91
Error in Visual Project 10 48
CSS styling problem 3 27
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question