WCF中通过配置文件来创建启动服务
来源:互联网 发布:数据段字节变量 编辑:程序博客网 时间:2024/05/21 19:43
//1.类库
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;namespace WCFServiceDemo{ [ServiceContract] public interface IHelloService { [OperationContract] DateTime getDateTime(); }}
2. Winform应用程序(宿主程序)
using System;using System.Collections.Generic;using System.Linq;using System.Text;using WCFServiceDemo;namespace WinformHello{ public class HelloService:WCFServiceDemo.IHelloService { public DateTime getDateTime() { return DateTime.Now; } }}
3.配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WinformHello.HelloService" behaviorConfiguration="TestBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/Hello"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="WCFServiceDemo.IHelloService"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
4.启动服务
public partial class Form1 : Form { public Form1() { InitializeComponent(); } ServiceHost host = null; private void button1_Click(object sender, EventArgs e) { host = new ServiceHost(typeof(WinformHello.HelloService)); host.Open(); label1.Text = "服务已启动"; } }
- WCF中通过配置文件来创建启动服务
- WCF :通过配置文件来托管服务
- WCF中配置文件部署服务
- 创建tomcat的服务,删除服务,通过服务来启动项目
- wcf学习第4天(通过配置文件来设置)
- WCF服务配置文件中各节点的意义。
- c#通过创建Windows服务启动程序
- WCF服务启动错误
- WCF(1)----服务创建
- 如何通过pfile来创建spfile来启动数据库
- Java中通过配置文件创建Mysql数据库连接
- WCF中配置文件解析
- WCF中配置文件解析
- WCF中配置文件解析
- WCF中配置文件解析
- WCF中配置文件解析
- 在Sharepoint2010的Webpart中调用WCF服务(二)创建webpart并调用WCF服务
- 第一章 基础 (续 通过代码和配置文件写一个WCF服务)
- iOS编译ffmpeg
- ios下的蓝牙4.0
- 学电脑,就得知道电脑每个键的用处,赶快保存起来
- 子类化QWidget iconEditor实现<三>
- C++ 按关键字搜索文件夹中的文件 & 全盘符搜索文件
- WCF中通过配置文件来创建启动服务
- linux tar 加压、压缩命令详解
- Linux常用命令功能集
- Oracle分页查询中排序与效率问题
- 多继承时的构造函数
- 第十四周项目三:CSolid类
- 软件开发中的“宫心斗”
- iOS设备的UDID是什么?苹果为什么拒绝获取iOS设备UDID的应用?如何替代UDID?
- MCMC-蒙特卡洛算法