473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

web services time out issue

145 100+
http://addressof.com/blog/archive/2004/04/26/637.aspx

I found the article but I am not sure how and where to implement the code.

Expand|Select|Wrap|Line Numbers
  1. Protected Overrides Function GetWebRequest(ByVal uri As System.Uri) As System.Net.WebRequest
  2.  Dim webRequest As Net.HttpWebRequest = CType(MyBase.GetWebRequest(uri), Net.HttpWebRequest)
  3. webRequest.KeepAlive = False
  4. Return webRequest
  5. End Function
I copied the exact code and put it right under the imports statement on the top of the form code but geting error.
May 28 '08 #1
3 2257
dorandoran
145 100+
This article describs how to implement the code.
http://weblogs.asp.net/jan/archive/2.../28/63771.aspx

Solving "The underlying connection was closed: An unexpected error occurred on a send." (Webservices)
UPDATE: For solution when using WSE, see here!

Sometimes when you invoke a webservice the call fails with the following exception:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
at System.Web.Services.Protocols.WebClientProtocol.Ge tWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters)
at ...

In some cases the first call to the webservice works just fine, but if in the following few minutes no new call to the webservice is made, the next call would throw the exception shown above. This problem could be solved by altering the generated proxy class; in the GetWebRequest function the KeepAlive property must be set to false. This can be accomplished by following these steps:

Add a Web Reference using the normal way (if you haven't already added one ofcourse).
Make sure Show All Files menu item is enable in the Project menu.
In the Solution Explorer window, navigate to:
Web References
<Name of your webservice>
Reference.map
Reference.cs (or .vb)
Open the Reference.cs file and add following code in the webservice proxy class:
Expand|Select|Wrap|Line Numbers
  1. protected override System.Net.WebRequest GetWebRequest(Uri uri)
  2. {
  3.  System.Net.HttpWebRequest webRequest = 
  4.   (System.Net.HttpWebRequest) base.GetWebRequest(uri);
  5.  webRequest.KeepAlive = false;
  6.  return webRequest;
  7. }
May 28 '08 #2
You might want to see this page for more details about The underlying connection was closed.
Mar 25 '09 #3
Frinavale
9,735 Expert Mod 8TB
Dorandoran, could you please explain the problem you're facing.
It seems you are having a problem solving another problem.
Could you please explain the original problem before you continue to use code that you don't fully understand?

Thanks,

-Frinny
Mar 31 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Niel | last post by:
Hello friends, I think this issue has been posted before but i have not been able to get any solution that is why i am posting it again in detail as to what exactly is happneing in my case. Hope...
3
by: ACP | last post by:
Hi all, Have a situation that my company has never run across before. Client is running NT4 for the domain server, using terminal services 2000 and running an application with a SQL Server...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
8
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string...
0
by: S.Subramanian Iyer | last post by:
Hello Everyone, This is an interesting issue that needs the community's attention and active participation. Lets begin from the top; Microsoft Visual Studio.NET provides excellent and extensive...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
4
by: peteh | last post by:
Hi All; I am trying to test the web services consumer example on a DB2 v9 ESE Windows server. I have tried 2 methods which both return the same error:...
2
by: J.Marsch | last post by:
All: I am having a problem with Microsoft Reporting Services. I am running a local report (RDLC) on ASP.Net. Running the report obviously can use a lot of memory because it must consume...
3
by: =?Utf-8?B?c2F2dmFz?= | last post by:
Do you know if microsoft has any tools or guidelines to calculate the hardware requirements for a server with windows server 2003 that will have a couple of .Net webservices and a couple of aspx...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.