WCF - Contract Name could not be found in the list of contracts
Posted
by user208662
on Stack Overflow
See other posts from Stack Overflow
or by user208662
Published on 2010-01-16T14:31:30Z
Indexed on
2010/06/12
23:32 UTC
Read the original article
Hit count: 270
wcf
Hello,
I am relatively new to WCF. However, I need to create a service that exposes data to both Silverlight and AJAX client applications. In an attempt to accomplish this, I have created the following service to serve as a proof of concept:
[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;
}
}
When I try to access this service, I receive the following error:
The contract name 'myService' could not be found in the list of contracts implemented by the service 'myService'.
What is the cause of this? How do I fix this?
Thank you
© Stack Overflow or respective owner