// wcf 服务项目下 我创建的一个student类。想在客户端调用 里面的方法。
namespace WcfService3
{
    [DataContract]
    public class Student
    {
        private string _id;
        private string _name;
        private string _password;        [DataMember]
        public string id
        {
            get { return _id; }
            set { _id = value; }
        }        [OperationContract] //是这样定义吗,        public Student(string _id, string _name, string _password)
        {
            id = _id;
            name = _name;
            password = _password;
        }        [OperationContract]  //是这样定义吗,客户端提示找不到这个方法        public string getID()
        {
            return id;
        }
}//客户端调用
 private void button3_Click(object sender, EventArgs e)
        {
            ServiceReference1.Service1Client serclient = new ServiceReference1.Service1Client();
            ServiceReference1.Student aa = serclient.getStudent();
            aa.getID(); //提示没有这个方法}

解决方案 »

  1.   

    你是用vs自带的向导创建的WCF吗?你有修改过WCF的配置文件吗?自带向导要求WCF服务继承IServer1类,你继承了吗?
      

  2.   

    public class Service1 : IService1
    向导已经创建好了,很简单!
    但是,现在我想自己再创建一个类Student,将发布出去
      

  3.   

    要使用自己定义的类,必须修改WCF的配置文件,默认的配置文件只能对IService1接口和Service1 处理,你可以修改这两个当中的方法,但是新增类则不行。