Solved

Necessary or optional to close a webservice client connection

Posted on 2012-03-13
3
267 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:knowlton
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
Comment Utility
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
Comment Utility
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:knowlton
Comment Utility
Thank you.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now