创建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. 关于TextView 的属性

    一.设置不同的字体和颜色值:questionDesTextView=(TextView)findViewById(R.id.question_des); SpannableStringBuilder ...

  2. 提高Interface Builder高效工作的8个技巧

    本文转载至 http://www.cocoachina.com/ios/20141106/10151.html iOS开发Interface Builder 本文译自:8 Tips for worki ...

  3. 自定义下拉刷新控件-CBStoreHouseRefreshControl

    本文转载至 http://www.cocoachina.com/ios/20141110/10177.html iOS开发自定义刷新CBStoreHouseRefres 介绍 这是一款在Storeho ...

  4. python 基础 5.2 类的继承

    一. 类的继承 继承,顾名思议就知道是它的意思,举个例子说明,你现在有一个现有的A类,现在需要写一个B类,但是B类是A类的特殊版,我们就可以使用继承,B类继承A类时,B类会自动获得A类的所有属性和方法 ...

  5. 九度OJ 1168:字符串的查找删除 (查找)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4276 解决:1699 题目描述: 给定一个短字符串(不含空格),再给定若干字符串,在这些字符串中删除所含有的短字符串. 输入: 输入只有1 ...

  6. 九度OJ 1046:求最大值 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9861 解决:4013 题目描述: 输入10个数,要求输出其中的最大值. 输入: 测试数据有多组,每组10个数. 输出: 对于每组输入,请输 ...

  7. redis自启动

    $ vi /etc/init.d/redis # chkconfig: 2345 90 10 # description: Redis is a persistent key-value databa ...

  8. quick-cocos2d-x教程11:实现http通信,并与站点php对接,可实现登录等常见功能

    手机游戏眼下是弱联网居多,http登录是经常使用功能.我们如今就来实现. 在启动时候.自己主动请求http. function MainScene:ctor()     local url = &qu ...

  9. java参数传递------真心是值传递

    未完待续 不同意的请尽管去深入看一下. 对象是引用传递没错,参数传递是值传递.

  10. [egret+pomelo]实时游戏杂记(4)

    了解了前后端的通信,下面就可以开始自己的业务逻辑了,首先玩家输入名称,选择角色后进入游戏世界. 服务端的demo中已经提供了一些简单的角色信息和属性,数据地址位于 game-server/config ...