web控件调用web服务方法时出现NotImplementedException
本文关键字:web NotImplementedException 方法 控件 调用 服务 | 更新日期: 2023-09-27 18:03:14
我有一个web表单,当提交到一个web服务,并记录在数据库中的表单数据。然后它返回到web控件,经过几次检查后,它返回到web服务并向预先指定的电子邮件地址发送电子邮件。我已经编译了代码没有错误,但是当我尝试执行代码时,我有一个NotImplementedException的问题,数据已经存储在数据库中,我尝试去CreateEmail方法开始发送电子邮件的过程。
看完这些:
http://msdn.microsoft.com/en-gb/library/system.notimplementedexception.aspx什么会抛出new NotImplementedException() ?到底是什么?
为什么存在notimplementdexception ?
我意识到它在说我的方法没有被实现或者不存在。
Visual Studio正在挑选方法并在智能感知中显示它,并且该方法确实包含代码,我在下面的一个非常基本的削减方式中包含了这些代码。
我在相同的方法中设置了一个更高的连接,称为"service",我知道它正在工作,因为它连接到我的服务,以便将数据存储在数据库中。
我已经检查了操作合同是否到位:
[OperationContract]
string CreateEmail(string name, string address, string town, string postcode, string email, string contact);
我有以下代码从我的web表单到我的服务:
if (DBresults == "0")
{
try
{
EmailResults = service.CreateEmail(name, address, town, postcode, email, contact);
}
catch (NotImplementedException ex)
{
service.Abort();
}
catch (CommunicationException ex)
{
service.Abort();
}
catch (TimeoutException ex)
{
service.Abort();
}
catch (Exception ex)
{
service.Abort();
throw ex;
}
}
然后在web服务本身中,我有以下代码(为了方便起见,我已经更改了名称,并删除了try的主体,以便于阅读):
namespace WcfSvc{
public class WcfSvc : IWcfSvc
{
public string CreateEmail(string name, string address, string town, string postcode, string email, string contact)
{
string sent = "1";
string fromEmail = "test@test.com";
try
{
//main bit of my sent code.
string sent = "done";
return sent;
}
catch (Exception ex)
{
string exMessage = ex.Message;
ex = null;
return exMessage;
}
}
}
}
我试图在CreateEmail的服务中设置一个断点,但它从未击中它,而是直接捕获错误。
我哪里错了?
编辑:得到的异常消息是:ex ={"该方法或操作未实现。"}
验证web。Config或app.config包含最新web服务的正确web地址。使用WCF测试客户端测试对web服务的调用。验证运行服务的进程是否具有最新的代码。