WCF服务端怎样接收andriod客服端传来的一个类
如题
数据契约
[DataContract]
public class User
{
[DataMember]
public string Name { set; get; }
[DataMember]
public int Age { set; get; }
}
[ServiceContract]
interface IServer
{
[OperationContract]
[ServiceKnownType(typeof(User))]
int GetStu(User user);
}
public class Service:IServer
{
public int GetStu(User user)
{
//Console.WriteLine("{0} \n {1}", user.Name, user.Age);
using (var writer = new StreamWriter(File.Open(@"d:\msmq.txt", FileMode.Append)))
{
writer.WriteLine("{0} - {1}", user.Name, user.Age);
writer.WriteLine();
writer.Flush();
}
return 1;
}
}