WCF的第一个例子

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenhaiming123/article/details/85217922

一、建立项目
在这里插入图片描述
二、测试例子

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            ServiceReference1.Service1Client sc = new WindowsFormsApplication1.ServiceReference1.Service1Client();
            MessageBox.Show(sc.GetData(5));
            ServiceReference1.CompositeType ct = new WindowsFormsApplication1.ServiceReference1.CompositeType();
            ct.BoolValue = false;
            ct.StringValue = "Hello,WCF";

            ServiceReference1.CompositeType newct = new WindowsFormsApplication1.ServiceReference1.CompositeType();
            newct = sc.GetDataUsingDataContract(ct);
            MessageBox.Show(newct.StringValue);

        }
    }
}

猜你喜欢

转载自blog.csdn.net/chenhaiming123/article/details/85217922