views:

133

answers:

3

My web configuration looks as follows:

<system.web>
    <compilation debug="false"/>
    <httpRuntime executionTimeout="90"/>
</system.web>

This is fine for most webservice functions but one function has a query that is running a very long (5 minutes) time and will be stopped before it has finished. Is it possible to set the runtime to 5 minutes for this webservice alone?

E.g.:

  MyWebServices.asmx?op=WS_LongMethod --> Timeout of 5 minutes

I've thought about running the database query async (fire and forget) but it doesn't seem possible with sybase/oracle through ODBC.

+5  A: 

Yes, you can do that. In the web.config, you'll need to add a <location/> element:

<location path="Path_To_Your_Service.asmx">
    <system.web>
        <httpRuntime executionTimeout="90"/>
    </system.web>
</location>

The <location/> element gives you a mechanism whereby you can apply web.config attributes to specific paths within your site.

Richard
I forgot to mention: the `<location/>`'s path attribute lets you localise the settings contained within the element to the specific file or path you specify!
Richard
That would change all my webservice functions. I just want to change one webfunction, e.g. "MyWebServices.asmx?op=WS_DoLongQuery"
Carra
Sorry, your initial post said "Is it possible to set the runtime to 5 minutes for this webservice alone?" - not a specific Web Method. I've never tried to specify a query string in the path attribute - have you tried it?
Richard
A: 

Did you check the .Timeout property of web service?

Indicates the time an XML Web service client waits for a synchronous XML Web service request to complete (in milliseconds).

KMan
From the documentation: " Indicates the time an XML Web service <b>client</b> waits for a synchronous XML Web service request to complete (in milliseconds)."
Carra
@Carra: Sorry, if I misunderstood. I am assuming that a client calls your web service like `MyWebServices.asmx?op=WS_LongMethod`, so If you're using a proxy to call webservice methods, then this timeout setting would be useable.
KMan
I know, we've already set a time-out at the client side. For that long query function we just set the Timeout at the client side to 5 minutes.
Carra
@Downvoter: Why the down vote?
KMan
+2  A: 

You can use a delegate within your webservice to call another method asynchronously. Within this method you can do your database IO. This means you will return to the caller before the operation is complete, however if you generate a unique ID and store any info related to that ID, then you can retrieve it at a later date.

ck
I tried to start the operation with a QueueUserWorkItem (or fire and forget delegate) and that works fine. However, I'd like to make sure that the thread is stopped if the query takes longer than 5 minutes.
Carra