简体   繁体   English

Asp.net C#异步调用Web Service方法

[英]Asp.net C# Asynchronous call to Web Service method

I have a following scenario: 我有以下情况:

1) User uploads a file via Asp.net web page. 1)用户通过Asp.net网页上传文件。
2) Web page passess the file to FileFlowManagerBLL which checks the file and uploads it to the database 2)网页将文件传递给FileFlowManagerBLL,后者检查文件并将其上传到数据库
3) I would like to call a background web service method, which is by the way in the same project, so that the web service starts a huge job of number crunching from the uploaded file. 3)我想调用一个后台Web服务方法,该方法是在同一项目中进行的,以便Web服务从上载的文件开始大量的数字处理工作。 After calling the web service method I would like to return the control back to the user without waiting for it to finish, displaying a message that the file has been update successfully and user will receive an email once the data crunching is complete. 调用Web服务方法后,我想将控件返回给用户而不等待它完成,显示一条消息,说明文件已成功更新,一旦数据整理完成,用户将收到一封电子邮件。
4) Web service completes the number crunching in lets say 30 - 60 mins or may be more and calls the relevant code that sends an email to the user. 4)Web服务完成30分钟至60分钟或更长时间的数字运算,并调用向用户发送电子邮件的相关代码。

I need some quidance for implementing step 3 ie how to call a web service method asynchrously so that the control is returned to the user and he/she can view other pages of the web application while the number crunching is being done. 我需要一些步骤来实现步骤3,即如何异步调用Web服务方法,以便将控件返回给用户,并且他/她可以在进行数字整理时查看Web应用程序的其他页面。

One way would be to host your WCF service as a Windows service. 一种方法是将WCF服务托管为Windows服务。 Your initial web service (after it checks the file) could write it to a certain directory. 您的初始Web服务(在检查文件之后)可以将其写入特定目录。 Then in your Windows Service you can create a FileSystemWatcher that looks for new files in that directory, and if it finds any can call your processing method. 然后,在Windows服务中,您可以创建一个FileSystemWatcher,该文件查找该目录中的新文件,如果找到,则可以调用您的处理方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM