WCF寄宿与IIS里时遇到的问题

WCF寄宿与IIS里时遇到的问题,第1张

概述     最近在公司做了一个小的视频处理网站,由于视频处理,网站在不同的服务器上,所以处理视频的时候得在网站服务器上通过wcf请求视频处理服务器处理视频,并将结果返回。我在写好这个wcf服务后寄宿到IIS里时遇到了不少的问题,下面是问题的描述,以及解决的方法。    问题1:     由于我这里的wcf服务是采用“WSHttpBinding”的方式,即安全绑定模式,客户端在引用这个服务后所生成的终

 

   最近在公司做了一个小的视频处理网站,由于视频处理,网站在不同的服务器上,所以处理视频的时候得在网站服务器上通过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">
        <endpoi nt 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的数据传输量,问题就解决了。 希望以后遇到这些问题后能快速消灭它,呵呵

总结

以上是内存溢出为你收集整理的WCF寄宿与IIS里时遇到的问题全部内容,希望文章能够帮你解决WCF寄宿与IIS里时遇到的问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1044533.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)