Solved

Necessary or optional to close a webservice client connection

Posted on 2012-03-13
3
270 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
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:knowlton
ID: 37720329
Thank you.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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