How to change Connection Time-Out value for Web Service? (VBA in Excel)

T

Tim Laplaca

Using VBA under Excel, I added a web service with "Microsoft Office
2003 Web Services Toolkit".

Sometimes the service I connect to is slow and the VB times out with
"Connection:Connection time out.", so I need to increase how long it
waits before timing out.

With some web searches, I found there is a Timeout property associated
with SOAP: Example - Property("Timeout") = 30000

However, I have been unable to figure out how, if it's possible, to set
this property with a service created with the Web Services toolkit.

My service was created thusly:
Dim qservice As New clsws_gwcdrService23

where clsws_gwcdrService23 is the class created by the toolkit from the
wsdl file I gave it the URL for.

Thanks much for any assitance,
Tim
 
S

Stephen Bullen

Hi Tim,
Using VBA under Excel, I added a web service with "Microsoft Office
2003 Web Services Toolkit".

Sometimes the service I connect to is slow and the VB times out with
"Connection:Connection time out.", so I need to increase how long it
waits before timing out.

With some web searches, I found there is a Timeout property associated
with SOAP: Example - Property("Timeout") = 30000

However, I have been unable to figure out how, if it's possible, to set
this property with a service created with the Web Services toolkit.

My service was created thusly:
Dim qservice As New clsws_gwcdrService23

where clsws_gwcdrService23 is the class created by the toolkit from the
wsdl file I gave it the URL for.

Thanks much for any assitance,

If you look in the Class_Initialize method for the class generated by the
toolkit, you'll see it creates an instance of the SoapClient30 object.

Looking in the Object Browser, I see that object has both a
'ClientProperty' and 'ConnectorProperty' property, so it might be
possible to set one of those in the class:


Set sc_gwcdrService23 = New SoapClient30
sc_gwcdrService23.ConnectorProperty("Timeout")=3000

I haven't tested it though!

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk
 
R

Revtim

Thanks for the reply Stephen,

when I try that code, at runtime I get the error "Client:Soap client
is not initialized. HRESULT=0x80040007: Uninitialized object" when
trying to set the connector property.

I suppose perhaps the next step is to initialize the sc_gwcdrService23.
But, is this object really the service I need to access, or a generic
Soap Object with no relation to the service I added with the toolkit?
Perhaps does it get linked to the URL of the service during
initialization?

Thanks again for the help,
Tim
 
S

Stephen Bullen

Hi Tim,
when I try that code, at runtime I get the error "Client:Soap client
is not initialized. HRESULT=0x80040007: Uninitialized object" when
trying to set the connector property.

I suppose perhaps the next step is to initialize the sc_gwcdrService23.
But, is this object really the service I need to access, or a generic
Soap Object with no relation to the service I added with the toolkit?
Perhaps does it get linked to the URL of the service during
initialization?

Oops, sorry! Try putting it at the end of the Class_Initialize (where
the other properties are set). FWIW, the toolkit analyses the web service
information to identify which properties and methods, then creates a
class that mimics those properties and methods (as best it can), passing
the call on to the Soap Object. It's in the Class_Initialize that the
Soap object gets initialized to point to the web service.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk
 
R

Revtim

Stephen said:
Oops, sorry! Try putting it at the end of the Class_Initialize (where
the other properties are set). FWIW, the toolkit analyses the web service
information to identify which properties and methods, then creates a
class that mimics those properties and methods (as best it can), passing
the call on to the Soap Object. It's in the Class_Initialize that the
Soap object gets initialized to point to the web service.

Ah, I see. You mean the method Class_Initialize that's in the class
generated by the tool.

Thank you much, I think this likely solves my problem!

One last question: are the units of the property in milliseconds?
Thanks again,
Tim
 
S

Stephen Bullen

Hi Tim,
Ah, I see. You mean the method Class_Initialize that's in the class
generated by the tool.
Exactly.

One last question: are the units of the property in milliseconds?

No idea. Probably.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top