一:截图

二:调用代码

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 = ;
} #region 方法一
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length > )
{
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 > )
{
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默认实例的更多相关文章

  1. 使用C#创建及调用WCF完整实例 (Windows服务宿主)

    关于WCF的概念.原理.优缺点等,在这里就不多说了,网上很多,可以自行搜索,比我解释的要专业的多. 这里直接说使用Windows 服务(Windows Service)作为宿主如何实现,其它方式不在此 ...

  2. UI层调用WCF服务实例(源码)

    WCF原理性的东西,暂时还没有深入研究,只是在公司的项目中使用到了,会调用,然后再多做了一些了解,现在将它抽出来了一个小实例,写了一个WCF的demo. 我写的这个WCF.Demo主要包括数据契约和服 ...

  3. WCF默认实例的解读

    一:图片 IService1.cs是定义的接口,包含对Service.方法和方法用的类的声明的声明 Service1.cs是对接口的实现,包含实现的方法 代码注释: using System; usi ...

  4. ASP.NET中使用HttpWebRequest调用WCF

    最近项目需要和第三网站进行数据交换,第三方网站基本都是RESTfull形式的API,但是也有的是Web Service,或者.NET里面的WCF.微软鼓励大家使用WCF替代Web Service. W ...

  5. WCF简单实例--用Winform启动和引用

    以订票为例简单应用wcf程序,需要的朋友可以参考下 本篇转自百度文档,自己试过,确实可以用. 以订票为例简单应用wcf 新建一个wcf服务应用程序 在IService1.cs定义服务契约 namesp ...

  6. WCF分布式开发步步为赢(9):WCF服务实例激活类型编程与开发

    .Net Remoting的激活方式也有三种:SingleTon模式.SingleCall模式.客户端激活方式,WCF服务实例激活类型包括三种方式:单调服务(Call Service),会话服务(Se ...

  7. C# 一个WCF简单实例

    以订票为例简单应用wcf 新建一个wcf服务应用程序 在IService1.cs定义服务契约 复制代码 代码如下: namespace WcfDemo { // 注意: 如果更改此处的接口名称 &qu ...

  8. PHP调用WCF提供的方法

    一.准备工作 1.安装wampserver:过程略 2.配置wampserver: 2.1打开php.ini文件,去掉 ;extension=php_soap.dll 这里那个分号. 也有说把这个 ; ...

  9. WCF入门教程(四)通过Host代码方式来承载服务 一个WCF使用TCP协议进行通协的例子 jquery ajax调用WCF,采用System.ServiceModel.WebHttpBinding System.ServiceModel.WSHttpBinding协议 学习WCF笔记之二 无废话WCF入门教程一[什么是WCF]

    WCF入门教程(四)通过Host代码方式来承载服务 Posted on 2014-05-15 13:03 停留的风 阅读(7681) 评论(0) 编辑 收藏 WCF入门教程(四)通过Host代码方式来 ...

随机推荐

  1. 内存管理概述、内存分配与释放、地址映射机制(mm_struct, vm_area_struct)、malloc/free 的实现

    http://blog.csdn.net/pi9nc/article/details/23334659 注:本分类下文章大多整理自<深入分析linux内核源代码>一书,另有参考其他一些资料 ...

  2. RT: np - new sbt project generation made simple(r)

    np - new sbt project generation made simple(r) As pointed out in the comments by @0__ below, there's ...

  3. CoreText实现图文混排之点击事件

    今天呢,我们继续把CoreText图文混排的点击事件补充上,这样我们的图文混排也算是圆满了. 哦,上一篇的链接在这里 http://www.jianshu.com/p/6db3289fb05d Cor ...

  4. Another app is currently holding the yum lock; waiting for it to exit... 怎么解决

    Another app is currently holding the yum lock; waiting for it to exit... 怎么解决 这个问题说明你的程序yum程序正在运行,必须 ...

  5. Oracle 存储过程(2)

    http://www.cnblogs.com/chinafine/archive/2010/07/12/1776102.html http://blog.itpub.net/29485627/view ...

  6. windows安装服务

    我安装了windows服务的时候监控其他机子的时候,我在调试的时候用的是Account是其他用户是可以正常的,但是安装成服务的时候,老是被拒绝. 后来我将Account改成NetworkService ...

  7. RSA加密算法正确性证明

    RSA加密算法是利用大整数分解耗时非常大来保证加密算法不被破译. 密钥的计算过程为:首先选择两个质数p和q,令n=p*q. 令k为n的欧拉函数,k=ϕ(n)=(p−1)(q−1) 选择任意整数a,保证 ...

  8. 跟我学android-Notification

    Notification 可以理解为通知的意思,会出现在通知栏,比如来了一条短信 使用 Notification 有以下3个步骤: 1. 创建 NotificationManager的对象 2.为No ...

  9. C++中public、protected、private

    C++中public.protected.private 第一:private, public, protected 访问标号的访问范围. private:只能由  1.该类中的函数. 2.其友元函数 ...

  10. win7设置虚拟wifi

    1. cmd,使用管理员权限打开: 2. 设置:netsh wlan set hostednetwork mode=allow ssid=ABCD key=12345678 mode:是否开启虚拟wi ...