Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / July 2006

Tip: Looking for answers? Try searching our database.

Calling web services from .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott Baierl - 18 Jul 2006 16:08 GMT
I have an ASP.NET application that calls web services on another host.  Is
there a way that you can control the lifetime of the underlying TCP
connections that .NET uses to make the web service calls?  From what I
understand, by default, .NET is configured to use a maximum of two
connections, and those connections stay open for up to 100 seconds after the
last data was sent/received.  Is there a way to control the lifetime of
those underlying connections?  In other words, can I have .NET use a
different connection for each request, or, time out the existing connection
quickly, so that it needs to create a new connection more often than the 100
second default timeout?  Thanks in advance.
CaffieneRush@gmail.com - 20 Jul 2006 12:57 GMT
You can set the Timeout property on the web service proxy instance
before you make a call to the web method.

Dim ws As WebServiceA
ws.Timeout = 10 * 1000 * 60   '10 minutes

Dim myResult As Integer

Try
 myResult = ws.GetMyResult()

 'Do something with myResult

Catch wex As WebException

 'Check and handle the web exception

End Try

The web service client will now wait 10 minutes before timing out.
If you want the client to wait indefinitely (maybe for debugging) then
set the Timeout to -1

HTH
Andy

> I have an ASP.NET application that calls web services on another host.  Is
> there a way that you can control the lifetime of the underlying TCP
[quoted text clipped - 6 lines]
> quickly, so that it needs to create a new connection more often than the 100
> second default timeout?  Thanks in advance.
Scott Baierl - 21 Jul 2006 19:43 GMT
Thank you.  I'll give that a try.

> You can set the Timeout property on the web service proxy instance
> before you make a call to the web method.
[quoted text clipped - 36 lines]
>> 100
>> second default timeout?  Thanks in advance.
Scott Baierl - 21 Jul 2006 19:48 GMT
That sets the amount of time that a webservice call waits for the completion
of a synchronous webservice call.  That's not what I need.  What I need is a
way to control how long the underlying TCP connection is cached or kept open
after the call has completed.

> You can set the Timeout property on the web service proxy instance
> before you make a call to the web method.
[quoted text clipped - 36 lines]
>> 100
>> second default timeout?  Thanks in advance.
Ramya A - 26 Jul 2006 22:47 GMT
I think this can be possible by utilizing a timer in your ASP page for
a set interval.
Eveytime the interval laspses, it comes back to the timer and calls the
webservice again if the response results are not yet received.
You can also use waitforresponse property on the HTTP request object
and check for readystate of the HTTP request object in addition to the
timer.

Hope this helps.
Ramya

> I have an ASP.NET application that calls web services on another host.  Is
> there a way that you can control the lifetime of the underlying TCP
[quoted text clipped - 6 lines]
> quickly, so that it needs to create a new connection more often than the 100
> second default timeout?  Thanks in advance.
Scott Baierl - 29 Jul 2006 02:21 GMT
I found the solution to my problem.  It involves adding the following
override to my proxy class:

protected override System.Net.WebRequest.GetWebRequest(Uri uri)
{
   System.Net.Http.WebRequest webRequest =
(System.Net.Http.WebRequest)base.GetWebRequest(uri);
   webRequest.KeepAlive = false;
   return webRequest;
}

This code forces .NET to create a new connection for each web service
request, closing the connection when the request has finished.

>I have an ASP.NET application that calls web services on another host.  Is
>there a way that you can control the lifetime of the underlying TCP
[quoted text clipped - 6 lines]
>quickly, so that it needs to create a new connection more often than the
>100 second default timeout?  Thanks in advance.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.