日期:2014-05-16 浏览次数:20924 次
[DataContract]
public class Data{
[DataMember]
public string A;
}
[ServiceContract]
public interface Iservice
{
[OperationContract]
string CollectData(Data data); //服务器操作
}
public class Service : Iservice
{
public string CollectData(Data data)
{
Console.WriteLine("A 是 {0};",data.A);
Console.WriteLine("B 是 {0};", data.B == null ? "null" : data.B);
Console.WriteLine("C 是 {0};",data.C);
return String.Format("A 是 {0},B 是 {1},C 是 {2}", data.A, data.B == null ? "null" : data.B, data.C);
}
}
using (Proxy proxy = new Proxy(new WSHttpBinding(), new EndpointAddress(new Uri("http://localhost:8732/WCF.Third/Service/"))))
{
MainConlose.Data data = new MainConlose.Data()
{
A="StringA"
};
Console.WriteLine(proxy.CollectData(data));
Console.WriteLine("完成发送Data");
Console.Read();
}