我对WCF比较陌生.但是,我需要创建一个向Silverlight和AJAX客户端应用程序公开数据的服务.为了实现这一目标,我创建了以下服务作为概念证明:
[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;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试访问此服务时,收到以下错误:
在服务'myService'实现的合同列表中找不到合同名称'myService'.
这是什么原因?我该如何解决?
谢谢
| 归档时间: |
|
| 查看次数: |
54173 次 |
| 最近记录: |