WCF IIS部署
创建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部署的更多相关文章
- [WCF]IIS部署到新系统
最近为以前的一个企业部署软件的时候,接触到WCF,通过博客园大佬的系列文章和一些书籍,基本了解了一些.简单说也算是SOA一种方式,提供某种服务,可以理解为一个类库,供其他项目使用,可以做到业务分离.但 ...
- WCF IIS 部署错误处理
做Web接口,原来一直用Web Service的,但是.Net 3.5后,Web Service变成了WCF.代码的编写上,把WebMethod特性改成了OperationContract,然后把方法 ...
- IIS 部署WCF 4.0
上一章节讲解如何新建WCF服务,此文讲解如何在IIS上发布,并能正常访问 本地部署IIS 首先在本机安装IIS,IIS如何勾选,哪些是必须的?不太清楚,有清楚的大牛请指正!目前我的基本配置如下: 配置 ...
- IIS部署WCF
IIS部署WCF [转载自——http://www.cnblogs.com/starksoft/p/4992059.html] 1 部署IIS 1.1 安装WAS IIS原本是不支持非HTTP协议的服 ...
- WCF服务部署IIS
一.将WCF服务部署到IIS上 [转载自简单笑容——http://www.cnblogs.com/skdsxx/p/5072726.html ] 1.首先检测电脑上是否安装了IIS,一般来说Win7 ...
- WCF服务部署到IIS上,然后通过web服务引用方式出现错误的解决办法
本文转载:http://www.cnblogs.com/shenba/archive/2012/01/06/2313932.html 昨天在用IIS部署一个WCF服务时,碰到了如下错误: 理解了文档内 ...
- IIS 部署WCF服务注意事项
IIS部署WCF服务的时候经常会出现如下错误: System.ServiceModel.EndpointNotFoundException”类型的未经处理的异常在 WinformWcfHost.exe ...
- 宿主iis部署wcf
WCF学习笔记(4)——宿主iis部署wcf 本文将部署一个wcf+silverlight简单实例,以下是详细步骤: (环境:服务端win2003,iis6.0,asp.net4.0:客户端winXP ...
- .Net WCF服务部署IIS详细解析
官方解析:Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台.整合了原有的windows通 ...
随机推荐
- 解析域名得到IP
本文转载至 http://www.cocoachina.com/bbs/read.php?tid=142713&page=e&#a 分享类型:游戏开发相关 #include &l ...
- WCF基础之配置服务
在WCF应用编程中配置服务是其主要部分. 配置可以定义和自定义如何向客户端公开服务,包括服务地址,发送和接受消息的传输和编码,以及服务的安全类型. 服务的配置有两种:编码和使用config文件,大多数 ...
- 腾讯云上运行java程序过程
1: 购买服务器(腾讯云,阿里云等) 2:安装centos操作系统: 3:安装jdkhttp://www.cnblogs.com/Amos-Turing/p/7403696.html 4:安装数据库( ...
- PHP Framework
PHP Framework is built for PHP developers who need elegant toolkit to create full-featured web appli ...
- Java反射详解(转)
原文地址:http://www.importnew.com/17616.html 动态语言 动态语言,是指程序在运行时可以改变其结构:新的函数可以被引进,已有的函数可以被删除等在结构上的变化.比如众所 ...
- API的理解和使用——全局命令
全局命令 命令 功能 set 创建键值对 keys 遍历查看所有键 exists 判断一个键是否存在,1存在,0不存在 dbsize 当前数据库中有多少个键 del 删除一个或多个键 expire 设 ...
- Vue:实践学习笔记(6)——使用SLOT分发内容
Vue:实践学习笔记(6)——使用SLOT分发内容 Slot Slot是什么 Slot是父子组件的通讯方式,可以将父组件的内容显示到子组件之中. 使用SLOT前 比如我在定义组件的时候,在里面输入了X ...
- C++ 结构体多元素sort排序调用时的写法
//总结一下,结构体数据排序的快速写法 //以后在遇到需要写的时候,不要迟疑快速写完 struct node { int u, v, w; }a[10000]; //假设该结构体有3个元素 //现在仅 ...
- HDU 4539 郑厂长系列故事——排兵布阵 —— 状压DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4539 郑厂长系列故事——排兵布阵 Time Limit: 10000/5000 MS (Java/Ot ...
- 算法(Algorithms)第4版 练习 1.3.8
方法实现: //1.3.8 package com.qiusongde; import java.util.Iterator; import java.util.NoSuchElementExcept ...