我對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
這是不正確的。命名空間是必需的。大會是**不**。 –