创建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. mysqldump导入导出数据库总结

    mysqldump导入导出数据库总结 基本的使用方法总结: 1 导出所有库 系统命令行 mysqldump -uusername -ppassword --all-databases > all ...

  2. iOS_39_触摸解锁

    终于效果图: 控制器: // // BeyondViewController.m // 39_触摸解锁 // // Created by beyond on 14-9-17. // Copyright ...

  3. 【BZOJ4569】[Scoi2016]萌萌哒 倍增+并查集

    [BZOJ4569][Scoi2016]萌萌哒 Description 一个长度为n的大数,用S1S2S3...Sn表示,其中Si表示数的第i位,S1是数的最高位,告诉你一些限制条件,每个条件表示为四 ...

  4. EasyPlayer RTSP 安卓Android播放器显示模式设置方法

    一般对于一个播放器,应该支持如下几种显示模式: 等比例,最大化区域显示,不裁剪 等比例,最大区域显示,裁剪 拉伸显示,铺满全屏 要实现这几种显示模式,其实只要对播放控件的布局进行些许调整即可.那Eas ...

  5. Centos7升级python版本

    升级Python 我的安装目录是/home/python 下载 ` cd /home/python wget https://www.python.org/ftp/python/3.5.0/Pytho ...

  6. S2S4H整合注意问题

    整合过程中出现问题记录: 1.The import javax.servlet.http.HttpServletRequest cannot be resolved 解决办法:在tomcat的lib目 ...

  7. python cookbook第三版学习笔记三:列表以及字符串

    过滤序列元素: 有一个序列,想从其中过滤出想要的元素.最常用的办法就是列表过滤:比如下面的形式:这个表达式的意义是从1000个随机数中选出大于400的数据 test=[] for i in range ...

  8. 基于ajax和Form实现的注册

    注册 urls.py from django.contrib import admin from django.urls import path, re_path from app01 import ...

  9. Module.exports和exports的区别

    原文链接: https://www.ycjcl.cc/2017/02/10/module-exportshe-exportsde-qu-bie/ 学习Seajs时,看到了exports.doSomet ...

  10. python绘制圆和椭圆

    源自:https://blog.csdn.net/petermsh/article/details/78458585 1. 调用包函数绘制圆形Circle和椭圆Ellipse from matplot ...