Silverlight和WebService

时间:2011-03-07 11:01:06

标签: c# asp.net silverlight-4.0

我正在开发一个Silverlight项目,这是一种虚拟订单。最后,它完成输入数据并将其作为邮件发送。但是你无法在silverlight中发送邮件,因为它不允许我用于发送邮件的.NET库(System.Net.Mail),因此我使用Web服务发送该邮件。我使用这些功能:

  1. 在silverlight中

    public static void SendAsMail()
    {
        MailServiceSoapClient client = new MailServiceSoapClient(); // Client of WebService
        client.SendMailAsync(output.ToString()); // output is the text of mail
    }

  2. 在WebService中

    
    [WebService(Namespace = "http://www.mydomain.sk/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
        public class MailService : System.Web.Services.WebService
        {
            [WebMethod]
            public bool SendMail(string mail_text)
            {
                MessageBox.Show("connected");
                // function which sends mail
                return true;
            }
        }
    
    我添加了MessageBox函数以了解我是否访问过WebService。当我单击连接到WebService的按钮时,它什么都不做。

  3. 我不知道如何解决这个问题,请帮忙

    谢谢

2 个答案:

答案 0 :(得分:1)

您无法使用在IIS内部运行并且没有用户界面的Web服务的消息框,这不是Windows应用程序。

尝试使用Windows EventLog或文本文件中的日志记录方法替换messagebox.show,并检查其工作原理。

答案 1 :(得分:0)

创建一个返回值的服务方法。 然后,您可以使用它来返回任何错误消息或成功消息