如何从C#以异步模式调用Web服务 [英] How to call a web service in asynchronous mode from c#

查看:65
本文介绍了如何从C#以异步模式调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我只想以异步模式调用Web服务.
这样我的应用程序就不会等到结束发送邮件为止.一旦调用了Web服务,我的应用程序应继续显示成功发送邮件",并且发送电子邮件应在后台运行.


任何人都可以提供代码示例.

这是同步模式下的代码:

Hi All


I just want to call a Web service in asynchronous mode.
So that my application will not wait for the completion of sending the mail till the end.Once i call the web service,my application should go on with "Successfully send mail" and the sending email should run in the background.


Can anyone give the code samples.

Here is the code in synchronous mode:

using System.Web.Services;

/// <summary>
/// Summary description for KlassAktMailService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class KlassAktMailService : System.Web.Services.WebService
{

    public KlassAktMailService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string Send_Email(string strEmailAddrTo, string strEmailAddrCC, string strSubject, string strBody, string strFileName)
    {
        EmailAlert NewMail = new EmailAlert();
        return NewMail.SendEmail(strEmailAddrTo, strEmailAddrCC, strSubject, strBody, strFileName);
    }
}




我想要异步模式的代码.



谢谢与问候
froxy




I want the code for asynchronous mode.



Thanks and Regards
froxy

推荐答案

看看下面的链接"异步Web服务调用".
http://msdn.microsoft.com/en-us/library/55xs7d7f%28v = VS.90%29.aspx

您可能会考虑从Web服务本身异步发送电子邮件,因此请查看以下链接.

http://wiki.asp.net/page.aspx/536/send -asynchronous-mail-using-aspnet/

http://www.asp.net/general/videos/我如何与aspnet异步发送电子邮件
Have a look at below link for "Asynchronous Web Service Call".
http://msdn.microsoft.com/en-us/library/55xs7d7f%28v=VS.90%29.aspx

You may think of sending Emails Asynchronously from the Web Service it self, for that have a look at below links.

http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/

http://www.asp.net/general/videos/how-do-i-send-email-asynchronously-with-aspnet


这篇关于如何从C#以异步模式调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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