zoukankan      html  css  js  c++  java
  • 【问题总结】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>



    这样就修改了wtf的数据传输量,问题就解决了。 希望以后遇到这些问题后能快速消灭它,呵呵

    转自:http://www.cnblogs.com/ccmaycry/archive/2009/08/28/1555934.html

  • 相关阅读:
    学习鸟哥的Linux私房菜笔记(16)——Ubuntu中建立ftp服务
    gdal库对ENVI文件的一点支持不好
    学习鸟哥的Linux私房菜笔记(15)——文件系统
    学习鸟哥的Linux私房菜笔记(14)——硬件配置与管理
    使用jQuery加载script脚本
    学习鸟哥的Linux私房菜笔记(13)——用户管理
    学习鸟哥的Linux私房菜笔记(12)——系统监视2
    学习鸟哥的Linux私房菜笔记(11)——系统监视1
    学习鸟哥的Linux私房菜笔记(10)——bash2
    学习鸟哥的Linux私房菜笔记(9)——bash1
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/2647673.html
Copyright © 2011-2022 走看看