首页 > Windows开发 > 详细

winform调用WCF默认实例

时间:2015-02-05 09:22:56      阅读:359      评论:0      收藏:0      [点我收藏+]

一:截图

技术分享技术分享

二:调用代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WCFwinformTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
        }

        #region 方法一
            private void button1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Trim().Length > 0)
                {
                    WinformServiceReference.Service1Client winformSC = new WinformServiceReference.Service1Client();
                    int i = Convert.ToInt32(textBox1.Text.Trim());
                    MessageBox.Show(winformSC.GetData(i));
                }
            } 
        #endregion

        #region 方法二
            private void button2_Click(object sender, EventArgs e)
            {
                if (textBox2.Text.Trim().Length > 0)
                {
                    WinformServiceReference.Service1Client WinformSC = new WinformServiceReference.Service1Client();

                    WinformServiceReference.CompositeType ct = new WinformServiceReference.CompositeType();
                    ct.BoolValue = Convert.ToBoolean(comboBox1.Text);
                    ct.StringValue = textBox2.Text;

                    WinformServiceReference.CompositeType newCT = new WinformServiceReference.CompositeType();
                    newCT = WinformSC.GetDataUsingDataContract(ct);

                    MessageBox.Show(newCT.StringValue);
                }
            } 
        #endregion
    }
}

 

winform调用WCF默认实例

原文:http://www.cnblogs.com/hongmaju/p/4273911.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!