Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting web service timeout in vb.net

760 views
Skip to first unread message

Connolly@discussions.microsoft.com Bob Connolly

unread,
Mar 30, 2008, 10:37:01 PM3/30/08
to
How do I set the web service timeout in vb.net?

Steve Gerrard

unread,
Mar 30, 2008, 10:46:18 PM3/30/08
to
Bob Connolly wrote:
> How do I set the web service timeout in vb.net?

The web.config file for the service can have a <httpRuntime/> element, which
includes an executionTimeout attribute. The httpRuntime element goes in the
<system.web> element. See this link:

http://msdn2.microsoft.com/en-us/library/e1f13641(VS.80).aspx


Bob Connolly

unread,
Mar 30, 2008, 11:14:00 PM3/30/08
to
This link references asp.net. I am not using asp.net. I am accessing a web
service in a windows console program and it keeps timing out. I have read
that the default is 100 seconds. I want to increase this. What is the syntax
that I should use in my program to do this?
--
Bob Connolly

Steve Gerrard

unread,
Mar 31, 2008, 12:20:59 AM3/31/08
to
Bob Connolly wrote:
> This link references asp.net. I am not using asp.net. I am accessing
> a web service in a windows console program and it keeps timing out. I
> have read that the default is 100 seconds. I want to increase this.
> What is the syntax that I should use in my program to do this?
>

Ah, you mean your client app is timing out on its call to a web service.

If have an class based on WebClientProtocol, the base class for XML Web
Services, such as

Dim WebServe As TheWebService

Then it will have a timeout property:

WebServe.Timeout = 100000 ' 100 secs.

Cor Ligthert[MVP]

unread,
Mar 31, 2008, 12:24:24 AM3/31/08
to
Bob,'

A webservice = aspnet.

If you want to do this in a windows form, than don't talk about a webservice
timeout.
Steve gave you a very nice answer, on something that you were not asking.

Your question is to unclear to give a full answer, however probably you can
let your thread sleep a while.

Cor

"Bob Connolly" <BobCo...@discussions.microsoft.com> schreef in bericht
news:ADCAAEF0-5B01-4ADD...@microsoft.com...

Connolly@newsgroup.nospam Bob Connolly

unread,
Mar 31, 2008, 9:18:00 AM3/31/08
to
I apologize for not being clear enough in my question. I am still learning
about web services and it is sometimes hard for me to formulate questions
correctly. Please allow me to elaborate more: I have a vb.net windows console
program running on my pc that is serving as a client to pull down information
from a web service on a server. To do this I first added a Web reference (in
Solution Explorer) which I called AmiClmSvc_WebService (setting the Web
Reference URL property to point to the WSDL on my server with the web
service). Then in my code I have:

Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService.AmiClmSvc

Then later I have:

Dim AmiClaimSummary_Result As Object
AmiClaimSummary_Result =
AmiClmSvc_Proxy.AmiClaimSummary(SelectDate.ToString, SelectDate.ToString)

On this last step I am getting a timeout after 100 seconds, which I have
read is the default setting. I need to change the timeout value to something
higher than that, but do not know what syntax I need to use in order to do
that.

Can anyone help me with this?
--
Bob Connolly

Connolly@newsgroup.nospam Bob Connolly

unread,
Mar 31, 2008, 10:46:03 AM3/31/08
to
I have a vb.net windows console
program running on my pc that is serving as a client to pull down information
from a web service on a server. To do this I first added a Web reference (in
Solution Explorer) which I called AmiClmSvc_WebService (setting the Web
Reference URL property to point to the WSDL on my server with the web
service). Then in my code I have:

Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService.AmiClmSvc

Then later I have:

Dim AmiClaimSummary_Result As Object
AmiClaimSummary_Result = _

Steve Gerrard

unread,
Mar 31, 2008, 10:57:11 AM3/31/08
to
Bob Connolly wrote:
>To do this I first added a Web reference (in Solution
> Explorer) which I called AmiClmSvc_WebService (setting the Web
> Reference URL property to point to the WSDL on my server with the web
> service). Then in my code I have:
>
> Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService.AmiClmSvc
>
>> If have an class based on WebClientProtocol, the base class for XML
>> Web Services, such as
>>
>> Dim WebServe As TheWebService
>>
>> Then it will have a timeout property:
>>
>> WebServe.Timeout = 100000 ' 100 secs.


Are you saying that AmiClmSvc_Proxy does not have a Timeout property?


Connolly@newsgroup.nospam Bob Connolly

unread,
Mar 31, 2008, 11:18:01 AM3/31/08
to
Right, I have tried typing something like:

AmiClmSvc_Proxy.timeout = 5*60*1000

When I do this, there are no intellisense options and when I am done it
gives me a syntax error: "Declaration expected"

What syntax do I need to use to set the timeout?
--
Bob Connolly

Cor Ligthert[MVP]

unread,
Mar 31, 2008, 12:34:09 PM3/31/08
to
Bob,

Why not simple
\\\
Threading.Thread.sleep(100000)
///

-Cor


"Bob Connolly" <Bob Conn...@newsgroup.nospam> schreef in bericht
news:757B68FD-D0E9-4581...@microsoft.com...

Connolly@newsgroup.nospam Bob Connolly

unread,
Mar 31, 2008, 12:46:01 PM3/31/08
to
When I put this stement in my program as is it gives me the "Declaration
expected" syntax error. Could you please elaborate a little more? Where would
I put this statement? How will this increase the timeout period? Please keep
in mind that I am very new to the use of web services.

Thank you!
--
Bob Connolly

Steve Gerrard

unread,
Mar 31, 2008, 9:41:17 PM3/31/08
to
Bob Connolly wrote:
>>> To do this I first added a Web reference (in Solution
>>> Explorer) which I called AmiClmSvc_WebService (setting the Web
>>> Reference URL property to point to the WSDL on my server with the
>>> web service). Then in my code I have:
>>>
>>> Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService.AmiClmSvc
>>>
> Right, I have tried typing something like:
>
> AmiClmSvc_Proxy.timeout = 5*60*1000
>
> When I do this, there are no intellisense options and when I am done
> it gives me a syntax error: "Declaration expected"
>

I don't know what is up. I would not like to use a web service instance that had
no properties.

Maybe that should be
Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService

If you don't have intellisense showing anything, how does it even make a call?


Steven Cheng [MSFT]

unread,
Mar 31, 2008, 9:40:39 PM3/31/08
to
Hi Bob,

As for the ASP.NET webservice, it has a "executionTimeout" setting at
server-side which control the timeout behavior of the server-side
webservice request(also ASP.NET page request), default value is 110 secs:

#httpRuntime Element (ASP.NET Settings Schema)
http://msdn2.microsoft.com/en-us/library/e1f13641.aspx

Also, for .NET webservice client, the generated proxy (derived from
SoapHttpClientProtocol class) also has a timeout property(default value 90
secs). The following thread has mentioned both of them:

#Timeout value at the client proxy
http://bytes.com/forum/thread427729.html

You can try setting them to see whehter it helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Thread-Topic: Setting web service timeout in vb.net
>From: =?Utf-8?B?Qm9iIENvbm5vbGx5?= <Bob Conn...@newsgroup.nospam>
>Subject: Setting web service timeout in vb.net
>Date: Mon, 31 Mar 2008 07:46:03 -0700

Connolly@newsgroup.nospam Bob Connolly

unread,
Apr 1, 2008, 11:53:02 AM4/1/08
to
In the previous post you say:

Maybe that should be
Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService

When I try this I get a syntax error on AmiClmSvc_WebService that tells me
"Type Expected"

What else do you suggest?
--
Bob Connolly

Connolly@newsgroup.nospam Bob Connolly

unread,
Apr 1, 2008, 11:57:02 AM4/1/08
to
I went to the link that you sent. It tells me: "we can configure the
webservice's method call Timeout through the SoapHttpClientProtocol.Timeout
property"

How do I do this? It gives no specific directions and I could not find a
place where I could set this property. If I just put a line in my program
that says:

SoapHttpClientProtocol.Timeout = 100000

It give me a syntax error: "Declaration Expected"

--
Bob Connolly

Steven Cheng [MSFT]

unread,
Apr 1, 2008, 9:23:15 PM4/1/08
to
Hi Bob,

Thanks for your reply.

Sorry for haven't clarified it. The "SoapHttpClientProtocol" is the base
class of the webservice proxy (you generate through "Add WebReference" or
wsdl.exe). Therefore, you can directly set this "Timeout" property on the
client-side proxy. For example:

================
private void button2_Click(object sender, EventArgs e)
{
MyService.WebService myservice = new MyService.WebService();
myservice.Timeout = 1000 * 120;

string result = myservice.HelloWorld();
}

=================

also, you can manually open the auto-geneated proxy's code and found out
that your webservice proxy class is derived from "SoapHttpClientProtocol":

============
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="WebServiceSoap",
Namespace="http://tempuri.org/")]
public partial class WebService :
System.Web.Services.Protocols.SoapHttpClientProtocol {

private System.Threading.SendOrPostCallback
HelloWorldOperationCompleted;

===================

If there is still anything unclear, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?Qm9iIENvbm5vbGx5?= <Bob Conn...@newsgroup.nospam>
>References: <A14AA3D6-7CF1-4A60...@microsoft.com>
<zhnytl5k...@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Setting web service timeout in vb.net
>Date: Tue, 1 Apr 2008 08:57:02 -0700

Steve Gerrard

unread,
Apr 1, 2008, 11:40:33 PM4/1/08
to
Bob Connolly wrote:
> In the previous post you say:
>
> Maybe that should be
> Dim AmiClmSvc_Proxy As New AmiClmSvc_WebService
>
> When I try this I get a syntax error on AmiClmSvc_WebService that
> tells me "Type Expected"
>
> What else do you suggest?
>

I don't really know. If you aren't getting intellisense on your proxy object, I
don't see how you can do anything with it. Does it have any properties or
methods, when you dim it the original way, As New AmiClmSvc_WebService.AmiClmSvc
?

Connolly@newsgroup.nospam Bob Connolly

unread,
Apr 2, 2008, 9:06:01 AM4/2/08
to
I was finally able to resolve this issue, though I do not fully understand
why. When I originally coded as you suggested:

AmiClmSvc_Proxy.Timeout = 60 * 60 * 1000 '60 minutes

I got the errors that I described where I was not getting intellisense and
syntax error: "Declaration expected". I was coding this statement at the
Module level directly under the dim statement where I defined the
AmiClmSvc_Proxy in the first place. I was finally able to resolve the issue
when I coded the above statement within a SUB within the module. Suddenly the
intellisense started working and the timeout was changed. I don't understand
why the statement would work in one place and not the other, but it does.
Perhaps you can explain why? In any event, it is working and I thank you for
your help.

--
Bob Connolly

Connolly@newsgroup.nospam Bob Connolly

unread,
Apr 2, 2008, 9:22:00 AM4/2/08
to
I was finally able to resolve this issue, though I do not fully understand
why. When I originally coded as you suggested:

AmiClmSvc_Proxy.Timeout = 60 * 60 * 1000 '60 minutes

I got the errors that I described where I was not getting intellisense and
syntax error: "Declaration expected". I was coding this statement at the
Module level directly under the dim statement where I defined the
AmiClmSvc_Proxy in the first place. I was finally able to resolve the issue
when I coded the above statement within a SUB within the module. Suddenly the
intellisense started working and the timeout was changed. I don't understand
why the statement would work in one place and not the other, but it does.
Perhaps you can explain why? In any event, it is working and I thank you for
your help.

--

Steve Gerrard

unread,
Apr 2, 2008, 11:31:39 AM4/2/08
to
Bob Connolly wrote:
> I was finally able to resolve this issue, though I do not fully
> understand why. When I originally coded as you suggested:
>
> AmiClmSvc_Proxy.Timeout = 60 * 60 * 1000 '60 minutes
>
> I got the errors that I described where I was not getting
> intellisense and syntax error: "Declaration expected". I was coding
> this statement at the Module level directly under the dim statement
> where I defined the AmiClmSvc_Proxy in the first place. I was finally
> able to resolve the issue when I coded the above statement within a
> SUB within the module. Suddenly the intellisense started working and
> the timeout was changed. I don't understand why the statement would
> work in one place and not the other, but it does. Perhaps you can
> explain why? In any event, it is working and I thank you for your
> help.
>

If it is not in a method, it is not executable code. The assignment above is
something that has to happen at runtime, not something that can be set at
compile time.

Glad you figured it out. Be aware that there is also a timeout on the other end,
at the web service itself. Your app will now wait for 60 minutes (!), but the
web service is probably set to timeout sooner than that. Time will tell...


Steven Cheng [MSFT]

unread,
Apr 2, 2008, 9:27:24 PM4/2/08
to
Thanks for your reply Bob,

I'm glad that you've got it working. As for the new question ( the
""Declaration expected" error) you mentioned, here is my understanding:

In your original code, you used the following statement:

AmiClmSvc_Proxy.Timeout = 60 * 60 * 1000 '60 minutes

Is "AmiClmSvc_Proxy" the class/type name of the webservice proxy?

If so, this is because "Timeout" is not a static(shared) property, but a
instance property. Therefore, you need to create/declare and instance of
the proxy type and assign this property through the instance. For example:

dim myproxy as New AmiClmSvc_Proxy

myproxy.Timeout = xxxxx


Hope this help further clarify it.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?Qm9iIENvbm5vbGx5?= <Bob Conn...@newsgroup.nospam>
>References: <A14AA3D6-7CF1-4A60...@microsoft.com>
<zhnytl5k...@TK2MSFTNGHUB02.phx.gbl>

<40AC54C2-5330-4EAD...@microsoft.com>
<FmFxpAGl...@TK2MSFTNGHUB02.phx.gbl>


>Subject: RE: Setting web service timeout in vb.net

>Date: Wed, 2 Apr 2008 06:22:00 -0700

Steven Cheng [MSFT]

unread,
Apr 7, 2008, 8:01:56 AM4/7/08
to
Hi Bob,

Have you any further question on this? If there is anything else we can
help, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: stc...@online.microsoft.com (Steven Cheng [MSFT])
>Organization: Microsoft
>Date: Thu, 03 Apr 2008 01:27:24 GMT


>Subject: RE: Setting web service timeout in vb.net

>

Connolly@newsgroup.nospam Bob Connolly

unread,
Apr 10, 2008, 8:35:01 AM4/10/08
to
No, as I mentioned in a previous post, I was able to resolve the issue. Thank
you for your help!

alexnovosad

unread,
Jun 12, 2008, 11:39:15 AM6/12/08
to
Cor,

Please go back to school before you start offending other posters like Bob. I have no idea how you got your MVP or in what area your MVP is in, but I can tell it's not in .NET. "A webservice = aspnet" is an absurd statement. .NET Web services can be accessed from anywhere with anything and on any platform as long as that anything runs .NET. You can even call a web service from managed SQL since SQL 2005 came out, and you could call Web services from Windows Application since the beginning of .NET.

Bob, your question was 100% valid. To set timeout on a web service, first instantiate that web service. Let's say you called your web service MyFunkyService when you added Web Reference to it to your project. Then you'd instantiate it like this:

Dim myServiceInstance as New MyFunkyService.MyFunkyService

"MyFunkyService" repeats twice because by default when you add a web service, a proxy class is created and placed in the same namespace as class itself, so the first "MyFunkyService" refers to the namespace while the second one - to class name.

To set timeout to, say, 360 seconds, write:

myServiceInstance.Timeout = 360000 'in milliseconds

I think you're right that default is at 100 seconds or 100000 milliseconds.

0 new messages