WCF测试客户端服务操作未更新

时间:2013-03-26 12:53:13

标签: visual-studio-2010 wcf operations

我在WCF中很新。我正在创建一个新的WCF服务。我最初有1次手术。但过了一段时间后,我决定又增加两个。这两个新操作未出现在Microsoft WCF测试客户端中。我该如何解决我的问题?

Image here

更新:我评论了我的第一次操作和第二次操作。第三个操作在WCF测试客户端中更新。

Image here

@ Jen

 namespace MyService
    {
        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
        [ServiceContract]
        public interface IService1
        {
            [OperationContract]
            List<User> FindUser(string userName, string password);
            List<Service> GetServiceList();
            List<Message> GetMessageList(string userName);
        }
    }




namespace MyService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        public List<Service> GetServiceList()
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            var res = from r in context.Services select r;
            return res.ToList();
        }

        public List<User> FindUser(string userName, string password)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            var res = from r in context.Users where r.UserName == userName && r.Password == password select r;
            return res.ToList();
        }

        public List<Message> GetMessageList(string userName)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            var res = from r in context.Messages where r.ReceiverID == userName select r;
            return res.ToList();
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您需要在界面中的每个方法之前添加OperationContractAttribute