首页 技术 正文
技术 2022年11月15日
0 收藏 929 点赞 3,940 浏览 3715 个字
【问题总结】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>

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,084
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,559
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,408
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,181
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,818
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,901