0

我是 WCF 的新手。我正在创建一个新的 WCF 服务。我最初进行了 1 次手术。但过了一段时间,我决定再添加两个。2 个新操作不会出现在 Microsoft WCF 测试客户端中。如何解决我的问题?

图片在这里

更新:我注释掉了我的第一个操作和第二个操作。第三个操作在 WCF 测试客户端中得到更新。

图片在这里

@珍

 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();
        }
    }
}
4

1 回答 1

1

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

于 2013-03-26T13:32:28.553 回答