在WSS功能OnActivated事件中调用长时间运行的操作 [英] Call long running operation in WSS feature OnActivated Event

查看:172
本文介绍了在WSS功能OnActivated事件中调用长时间运行的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更具体地说-如何使用 [SoapDocumentMethod(OneWay = true)] 引用Web Service中的SPContext?

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

我们正在创建一项功能,该功能需要在创建网站时运行作业.该作业大约需要4分钟才能完成.因此,我们创建了一个Web服务,可以在激活该功能时调用它.这可行,但是我们希望它现在异步运行.我们已经找到了SoapDocumentMethod的OneWay属性,该属性可以很好地工作,但是SPContext现在为NULL.

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.

我们在_vti_bin虚拟目录中拥有我们的Web服务,因此在每个Windows Sharepoint Services站点中都可以使用它.我正在使用SPContext.Current.Web来获取站点并执行长时间运行的操作.我只想通过立即返回一个Soap响应并让该过程运行来开火,而忘记它.

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.

如何获取当前的SPContext?我以前可以在自己的网络服务中做到这一点:

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

SPWeb mySite = SPContext.Current.Web;

当我将 [SoapDocumentMethod(OneWay = true)] 属性应用于我的Web服务时,能否获得相同的上下文?

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

还是必须从URL重新创建SPWeb?

Or must I recreate the SPWeb from the url?

这类似于该线程: webservice单向和新的SPSite(myUrl)

更新:我已经尝试了以下两种方法,但是它们没有用:

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;

推荐答案

单向方法不能有返回值或任何out参数

One-way methods cannot have a return value or any out parameters

但是它们确实具有参数;不是吗?

But they do have in parameters don;t they?

调用webservice方法时,无法从featurereceiver传递当前站点的URL,然后执行 使用(SPSite网站=新的SPSite(urlPassedAsParameter)) 在Web服务方法中?

When you do the call to the webservice method, can't you pass in the url of the current site from the featurereceiver and then do using(SPSite site = new SPSite(urlPassedAsParameter)) in the web service method?

FeatureActivated替代中的SPFeatureReceiverProperties具有当前SPWeb或SPSite作为SPFeatureReceiverProperties.Parent.

The SPFeatureReceiverProperties in the FeatureActivated override has the current SPWeb or SPSite as SPFeatureReceiverProperties.Parent.

这篇关于在WSS功能OnActivated事件中调用长时间运行的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆