Call long running operation in WSS feature OnActivated Event

Posted by dirq on Stack Overflow See other posts from Stack Overflow or by dirq
Published on 2009-04-23T14:15:06Z Indexed on 2010/03/25 1:03 UTC
Read the original article Hit count: 472

Filed under:
|
|
|

More specifically - How do I reference SPContext in Web Service with [SoapDocumentMethod(OneWay=true)]?

We are creating a feature that needs to run a job when a site is created. The job takes about 4 minutes to complete. So, we made a web service that we can call when the feature is activated. This works but we want it to run asynchronously now. We've found the SoapDocumentMethod's OneWay property and that would work awesomely but the SPContext is now NULL.

We have our web services in the _vti_bin virtual directory so it's available in each Windows Sharepoint Services site. I was using the SPContext.Current.Web to get the site and perform the long running operation. I wanted to just fire and forget about it by returning a soap response right away and letting the process run.

How can I get the current SPContext? I used to be able to do this in my web service:

SPWeb mySite = SPContext.Current.Web;

Can I get the same context when I have the [SoapDocumentMethod(OneWay=true)] attribute applied to my web service?

Or must I recreate the SPWeb from the url?

This is similar to this thread: http://stackoverflow.com/questions/340192/webservice-oneway-and-new-spsitemyurl


Update: I've tried these two ways but they didn't work:

SPWeb targetSite = SPControl.GetContextWeb(this.Context);

SPWeb targetSite2 = SPContext.GetContext(this.Context).Web;

© Stack Overflow or respective owner

Related posts about wss-3.0

Related posts about web-services