创建WCFHost应用程序

Iservice.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Drawing;
namespace WCFHost
{ [ServiceContract]
interface IService
{ [OperationContract]
float Verify(byte[] img1, string id); }
}

Program.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace WCFHost
{
class Program
{
static void Main(string[] args)
{
WcfHostor.StartService();
Console.WriteLine("Start Sever Success!");
Console.Read(); }
}
}

Service.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using FRS;
namespace WCFHost
{
public class Service:IService
{
FeatureData fa = new FeatureData();
// public static FeatureData FD{get;set;} static void InitFRS()
{
//System.Console.WriteLine(System.Environment.CurrentDirectory);
FRSParam param = new FRSParam(); param.nMinFaceSize = ;
param.nRollAngle = ;
param.bOnlyDetect = true; FaceImage.Create(, param);
Feature.Init();
} static Service()
{
InitFRS();
} public float Verify(byte[] img1, string id)
{
try
{
Image img = FRS.Util.ImageHelper.BytesToImage(img1);
List<HitAlert> res = fa.Search(img, id).ToList();
if (res.Count == )
return ;
else
return res[].Details[].Score; }
catch
{
return -;
} }
}
}

WcfHosts

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Xml;
using System.Runtime.Serialization;
namespace WCFHost
{
class WcfHostor
{
static Uri baseAddress = new Uri("http://localhost:8099/Service");
static ServiceHost host;
public static void StartService()
{ host = new ServiceHost(typeof(Service), baseAddress);
BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxBufferSize = ;
binding.MaxReceivedMessageSize = ;
binding.TransferMode = TransferMode.Streamed;
binding.SendTimeout = new TimeSpan(, , ); // Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb); binding.ReaderQuotas.MaxDepth=;
binding.ReaderQuotas.MaxArrayLength=;
binding.ReaderQuotas.MaxBytesPerRead=;
binding.ReaderQuotas.MaxNameTableCharCount=;
host.AddServiceEndpoint(typeof(IService), binding, baseAddress); host.Open(); //// Create the ServiceHost.
//host = new ServiceHost(typeof(Service), baseAddress); //// Enable metadata publishing.
//ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); //smb.HttpsGetBinding
//smb.HttpGetEnabled = true;
//smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
//host.Description.Behaviors.Add(smb); //// Open the ServiceHost to start listening for messages. Since
//// no endpoints are explicitly configured, the runtime will create
//// one endpoint per base address for each service contract implemented
//// by the service.
//host.Open();
}
public static void EndService()
{
if (host != null)
{
host.Close();
}
}
}
}

至此,服务搭建完毕。

服务测试,建立C#应用程序

Reference->Add Service Reference

Address为上文 "http://localhost:8099/Service"

添加服务引用完毕。

WCF IIS部署的更多相关文章

  1. [WCF]IIS部署到新系统

    最近为以前的一个企业部署软件的时候,接触到WCF,通过博客园大佬的系列文章和一些书籍,基本了解了一些.简单说也算是SOA一种方式,提供某种服务,可以理解为一个类库,供其他项目使用,可以做到业务分离.但 ...

  2. WCF IIS 部署错误处理

    做Web接口,原来一直用Web Service的,但是.Net 3.5后,Web Service变成了WCF.代码的编写上,把WebMethod特性改成了OperationContract,然后把方法 ...

  3. IIS 部署WCF 4.0

    上一章节讲解如何新建WCF服务,此文讲解如何在IIS上发布,并能正常访问 本地部署IIS 首先在本机安装IIS,IIS如何勾选,哪些是必须的?不太清楚,有清楚的大牛请指正!目前我的基本配置如下: 配置 ...

  4. IIS部署WCF

    IIS部署WCF [转载自——http://www.cnblogs.com/starksoft/p/4992059.html] 1 部署IIS 1.1 安装WAS IIS原本是不支持非HTTP协议的服 ...

  5. WCF服务部署IIS

    一.将WCF服务部署到IIS上  [转载自简单笑容——http://www.cnblogs.com/skdsxx/p/5072726.html ] 1.首先检测电脑上是否安装了IIS,一般来说Win7 ...

  6. WCF服务部署到IIS上,然后通过web服务引用方式出现错误的解决办法

    本文转载:http://www.cnblogs.com/shenba/archive/2012/01/06/2313932.html 昨天在用IIS部署一个WCF服务时,碰到了如下错误: 理解了文档内 ...

  7. IIS 部署WCF服务注意事项

    IIS部署WCF服务的时候经常会出现如下错误: System.ServiceModel.EndpointNotFoundException”类型的未经处理的异常在 WinformWcfHost.exe ...

  8. 宿主iis部署wcf

    WCF学习笔记(4)——宿主iis部署wcf 本文将部署一个wcf+silverlight简单实例,以下是详细步骤: (环境:服务端win2003,iis6.0,asp.net4.0:客户端winXP ...

  9. .Net WCF服务部署IIS详细解析

    官方解析:Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台.整合了原有的windows通 ...

随机推荐

  1. leetcode笔记:Pow(x, n)

    一. 题目描写叙述 Implement pow(x, n). 二. 题目分析 实现pow(x, n).即求x的n次幂. 最easy想到的方法就是用递归直接求n个x的乘积,这里须要依据n的值,推断结果是 ...

  2. mongodb 配置单实例与双实例

    环境: centos6.5 192.168.16.70 配置单实例mongodb:[root@www soft]# tar xf mongodb-linux-x86_64-rhel62-3.2.7.t ...

  3. poj 2151Check the difficulty of problems<概率DP>

    链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~  求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...

  4. 马尔科夫链在第n步转移的状态的概率分布

  5. hadoop 小文件 挂载 小文件对NameNode的内存消耗 HDFS小文件解决方案 客户端 自身机制 HDFS把块默认复制3次至3个不同节点。

    hadoop不支持传统文件系统的挂载,使得流式数据装进hadoop变得复杂. hadoo中,文件只是目录项存在:在文件关闭前,其长度一直显示为0:如果在一段时间内将数据写到文件却没有将其关闭,则若网络 ...

  6. Git with SVN

    1)GIT是分布式的,SVN不是: 这 是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别.好处是跟其他同事不会有太多的冲突,自己写的代码放在自己电脑上,一段时间后再提交.合并, ...

  7. STO到底是什么?

    最近,链圈谈论最多的就是STO了,那STO到底是什么?现阶段发展得怎么样? 什么是STO STO英文全称Security Token Offering,即证券化通证发行,指在安全法律体系下受到约束的基 ...

  8. JavaScript学习笔记(持续更新)

    函数有“定义式”和“变量式”两种写法的区别 函数有“定义式”和“变量式”两种写法,两者基本区别不大.主要区别在于,如果在同一个代码块(Script标签对)定义两个同名的函数,浏览器在预编译代码时,使用 ...

  9. MVC+Ext.net零基础学习记录(一)

    由于最近开发一个项目,决定使用MVC+EXT.NET,决定将学习的这个过程记录下来 本人和很多菜鸟一样,之前既没有使用过MVC开发,也没有接触过EXT.NET,所以这将是一个大家共同学习的过程,文章中 ...

  10. java2 -宏观了解

    java2 -宏观了解 2016-01-24 16:17 308人阅读 评论(38) 收藏 举报  分类: JAVA(2)  版权声明:本文为博主原创文章,未经博主允许不得转载. Java2平台包括: ...