Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

WCF - Contract Name could not be found in the list of contracts

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

question from:https://stackoverflow.com/questions/2077615/wcf-contract-name-could-not-be-found-in-the-list-of-contracts

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your contract is the Interface not the implementation.

Somewhere in the config you have written myService instead of IJsonService.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...