【问题总结】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里时遇到的问题的更多相关文章

  1. Xamarin.Android 入门实例(2)之实现WCF 寄宿于IIS 的Web服务提供

    1.WCF 契约 ICalculator.cs using System.ServiceModel; namespace Contracts { [ServiceContract] public in ...

  2. 创建WCF服务寄宿到IIS

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

  3. WCF服务寄宿到IIS

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

  4. XP机器上WCF采用X509证书加密时IIS读取证书的授权

    XP机器上WCF采用X509证书加密时IIS读取证书的授权 XP下的授权命令为:winhttpcertcfg -g -c LOCAL_MACHINE\My -s 证书名称 -a "ASPNE ...

  5. WCF学习之旅—WCF寄宿前的准备(八)

    一.WCF服务应用程序与WCF服务库 我们在平时开发的过程中常用的项目类型有“WCF 服务应用程序”和“WCF服务库”. WCF服务应用程序,是一个可以执行的程序,它有独立的进程,WCF服务类协定的定 ...

  6. WCF寄宿方式

    WCF开发框架形成之旅---WCF的几种寄宿方式 WCF寄宿方式是一种非常灵活的操作,可以在IIS服务.Windows服务.Winform程序.控制台程序中进行寄宿,从而实现WCF服务的运行,为调用者 ...

  7. 将WCF寄宿在托管的Windows服务中

    在我之前的一篇博客中我介绍了如何发布WCF服务并将该服务寄宿于IIS上,今天我再来介绍一种方式,就是将WCF服务寄宿在Windows服务中,这样做有什么好处呢?当然可以省去部署IIS等一系列的问题,能 ...

  8. (转)发布Silverlight+WCF程序到IIS后,客户端访问数据库失败的解决方案

    转自url:http://greatverve.cnblogs.com/archive/2011/11/30/silverlight-wcf-pub.html 我们在编写Silverlight程序时, ...

  9. WCF服务部署IIS

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

随机推荐

  1. [array] leetCode-15. 3Sum-Medium

    leetCode-15. 3Sum-Medium descrition Given an array S of n integers, are there elements a, b, c in S ...

  2. jquery-12 jquery的ajax如何使用

    jquery-12 jquery的ajax如何使用 一.总结 一句话总结:就是$.get()和$.post()方法的使用,看参考手册就好,与php的交互. 1.删除元素的时候如何设置删除特效? ani ...

  3. 服务器svn 小乌龟 visualsvn server manager Tortoisesvn的部署使用

    这个主要说说实现hook,就是本地上传文件后,服务器svn将相应的文件也修改了,实现本地上传,可以及时在浏览器查看效果 首先安装visualsvn 可参考http://blog.csdn.net/zl ...

  4. ios开发图层layer与核心动画二:CATransform3D,CAlayear和UIView区别,layer的position和anchorpoint

    一:CATransform3D #import "ViewController.h" @interface ViewController () @property (weak, n ...

  5. iOS开发Quartz2D之八:图形上下文状态栈

    #import "DrawView.h" @implementation DrawView - (void)drawRect:(CGRect)rect { // Drawing c ...

  6. How to use ftp in a shell script

    转载How to use ftp in a shell script How to use ftp in a shell script Bruce EdigerBruce Ediger's home ...

  7. 【2001】关于N!的问题

    Time Limit: 3 second Memory Limit: 2 MB 编写程序,计算n!以十进制数形式表示的数中最右边一个非零数字,并找出在它右边有几个零. 例如:12!=1*2*3*4*5 ...

  8. [TypeScript] Find the repeated item in an array using TypeScript

    Say you have an array that has at least one item repeated. How would you find the repeated item. Thi ...

  9. Xmem

    http://blog.csdn.net/jthink_/article/details/43302615

  10. Hdu4771(杭州赛区)

    Stealing Harry Potter's Precious Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 ...