WCF寄宿与IIS里时遇到的问题
【问题总结】WCF寄宿与IIS里时遇到的问题
最近在公司做了一个小的视频处理网站,由于视频处理,网站在不同的服务器上,所以处理视频的时候得在网站服务器上通过wcf请求视频处理服务器处理视频,并将结果返回。我在写好这个wcf服务后寄宿到IIS里时遇到了不少的问题,下面是问题的描述,以及解决的方法。 问题1: 由于我这里的wcf服务是采用“WSHttpBinding”的方式,即安全绑定模式,客户端在引用这个服务后所生成的终结点配置(endpoint )就变成了
<endpoint address="服务器机器名/*.svc"> ,如果是在局域网里,通过机器名访问服务器本来是没什么问题的,由于视频处理服务器不在本地,而在广域网里面就不能机器名来访问服务器,会报无法解析的异常
“System.ServiceModel.EndpointNotFoundException)((System.Exception)(e.Result)).InnerException 没有终结点在侦听可以接受消息的 http://www-b5fbb257931:8080/VideoService.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参阅 InnerException 以了解详细信息。” 解决方法:
手动修改终结点配置 :)<endpoint address="IP地址/VideoService.svc"> 问题2: 上一个问题解决了,新的问题又来了,由于采用的WSHttpBingding的方式,这种直接通过Ip地址访问服务器的做法会被服务器认为是种不安全的访问,也会报异常说访问被拒绝。
解决办法:
修改服务器配置文件如下: <system.serviceModel> <services>
<service behaviorConfiguration="VideoService.Web.VideoServiceBehavior" name="VideoService.Web.VideoService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" contract="VideoService.Web.IVideoService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" maxReceivedMessageSize="20971510">
<readerQuotas maxStringContentLength="20971520" maxArrayLength="20971520"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel> 这样服务器就不会做安全认证了。 问题3: 由于我在向视频处理服务器请求的时候要向服务器传递文件,我的做法是把文件转化为二进制 byte[]数据类型来传递,但由于wcf默认的传递数据大小仅为64K,当我传递文件的超过的这个大小时候就会报 “WCF 读取 XML 数据时,超出最大数组长度配额(16384)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性,可增加此配额。 ”。有关详细信息,请参阅 InnerException。” 解决方案:
修改服务器配置文件: <system.serviceModel> <services>
<service behaviorConfiguration="VideoService.Web.VideoServiceBehavior" name="VideoService.Web.VideoService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" contract="VideoService.Web.IVideoService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" maxReceivedMessageSize="20971510">
<readerQuotas maxStringContentLength="20971520" maxArrayLength="20971520"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel> 再修改客户端配置文件:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IVideoService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<readerQuotas maxDepth="32" maxStringContentLength="20971520" maxArrayLength="20971520"
maxBytesPerRead="40960" maxNameTableCharCount="163840"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings> 问题4: 当我在silverlight里面实现上传文件到服务器的时候,总是报“NOTFOUND”异常, 这是由于WCF配置对文件上传大小的限制引起的,可以在 WEBCONFI文件里进行修改。添加类似以下配置代码 <basicHttpBinding>
<binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="UTF-8" sendTimeout="00:05:10" receiveTimeout="00:05:10" openTimeout="00:05:10" closeTimeout="00:05:10">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
WCF寄宿与IIS里时遇到的问题的更多相关文章
- Xamarin.Android 入门实例(2)之实现WCF 寄宿于IIS 的Web服务提供
1.WCF 契约 ICalculator.cs using System.ServiceModel; namespace Contracts { [ServiceContract] public in ...
- 创建WCF服务寄宿到IIS
一.WCF简介: Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台. 整合了原有的win ...
- WCF服务寄宿到IIS
一.WCF简介: Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台.整合了原有的wind ...
- XP机器上WCF采用X509证书加密时IIS读取证书的授权
XP机器上WCF采用X509证书加密时IIS读取证书的授权 XP下的授权命令为:winhttpcertcfg -g -c LOCAL_MACHINE\My -s 证书名称 -a "ASPNE ...
- WCF学习之旅—WCF寄宿前的准备(八)
一.WCF服务应用程序与WCF服务库 我们在平时开发的过程中常用的项目类型有“WCF 服务应用程序”和“WCF服务库”. WCF服务应用程序,是一个可以执行的程序,它有独立的进程,WCF服务类协定的定 ...
- WCF寄宿方式
WCF开发框架形成之旅---WCF的几种寄宿方式 WCF寄宿方式是一种非常灵活的操作,可以在IIS服务.Windows服务.Winform程序.控制台程序中进行寄宿,从而实现WCF服务的运行,为调用者 ...
- 将WCF寄宿在托管的Windows服务中
在我之前的一篇博客中我介绍了如何发布WCF服务并将该服务寄宿于IIS上,今天我再来介绍一种方式,就是将WCF服务寄宿在Windows服务中,这样做有什么好处呢?当然可以省去部署IIS等一系列的问题,能 ...
- (转)发布Silverlight+WCF程序到IIS后,客户端访问数据库失败的解决方案
转自url:http://greatverve.cnblogs.com/archive/2011/11/30/silverlight-wcf-pub.html 我们在编写Silverlight程序时, ...
- WCF服务部署IIS
一.将WCF服务部署到IIS上 [转载自简单笑容——http://www.cnblogs.com/skdsxx/p/5072726.html ] 1.首先检测电脑上是否安装了IIS,一般来说Win7 ...
随机推荐
- TCP套接字编程模型及实例
摘要: 本文讲述了TCP套接字编程模块,包括服务器端的创建套接字.绑定.监听.接受.读/写.终止连接,客户端的创建套接字.连接.读/写.终止连接.先给出实例,进而结合代码分析. PS:本文权当 ...
- C#无符号右移
/// <summary> /// 无符号右移,与JS中的>>>等价 /// </summary> /// & ...
- 怎么不让控制台system.out.println()打印
1.System类有一个public static void setOut(PrintStream out)方法,你可以调用这个方法将out重定向到任何一个全局PrintStream对象上: 2.如果 ...
- phpstorm 2018本地激活
这是简书上找到的,害怕以后找不到,记录一下网址为https://www.jianshu.com/p/133af2e4fe3f
- Android 各个版本号WebView
转载请注明出处 http://blog.csdn.net/typename/ powered by miechal zhao : miechalzhao@gmail.com 前言: 依据Googl ...
- POJ 2914 Minimum Cut 最小割算法题解
最标准的最小割算法应用题目. 核心思想就是缩边:先缩小最大的边.然后缩小次大的边.依此缩小 基础算法:Prime最小生成树算法 只是本题測试的数据好像怪怪的,相同的算法时间执行会区别非常大,并且一样的 ...
- mysql 按日期分组
select DATE_FORMAT(NOW(),'%Y%m%d') days,count(caseid) count from tc_case group by days; //date_forma ...
- css hover控制其他元素
<html> <body> <style> #a:hover {color : #FFFF00;} #a:hover > #b:first-child{col ...
- 号外:小雷将开发一款Java版的简易CMS系统
我的个人官网: http://FansUnion.cn 已经改版,隆重上线了,欢迎关注~持续升级中... 出于个人兴趣.技术总结.工作相关,我终于想要做一个简单的CMS系统了. 原来想研究,D ...
- Django之分页显示文章
1.项目:http://www.cnblogs.com/jasonhaven/p/7493422.html 2.任务描述:页面分页显示文章 3.源代码 后台: from django.core.pag ...