我对WCF比较陌生。但是,我需要创建一个将数据公开给Silverlight和AJAX客户端应用程序的服务。在试图做到这一点,我创建了以下服务作为一个概念证明:WCF - 在合同列表中找不到合同名称
[ServiceContract(Namespace="urn:MyCompany.MyProject.Services")]
public interface IJsonService
{
[OperationContract]
[WebInvoke(Method = "GET",
RequestFormat=WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
List<String> JsonFindNames();
}
[ServiceContract(Namespace="urn:MyCompany.MyProject.Services")]
public interface IWsService
{
[OperationContract(Name="FindNames")]
List<String> WsFindNames();
}
[ServiceBehavior(Name="myService", Namespace="urn:MyCompany.MyProject.Services")]
public class myService : IJsonService, IWsService
{
public List<String> JsonFindNames()
{ return FindNames(); }
public List<String> WsFindNames()
{ return FindNames(name); }
public List<string> FindNames()
{
List<string> names = List<string>();
names.Add("Alan");
names.Add("Bill");
return results;
}
}
当我试图访问这个服务,我收到以下错误:
合同名称'我的服务“无法在服务'myService'实施的合同列表中找到。
这是什么原因?我该如何解决?
谢谢
我刚刚删除了我的命名空间,试图解决与OP相同的问题,并且我的服务消失了。 – ProfK
这是不正确的。命名空间是必需的。大会是**不**。 –