Silverlight在调用wcf时传输数据过大返回Not Found的解决办法

原文地址: http://www.cnblogs.com/gavinyao/archive/2012/04/17/2454495.html

Silverlight在调用wcf时传输数据过大返回Not Found的解决办法

默认情况下,silverlight在调用wcf时,如果传递的数据中XML的Element的内容长度大于8192字节,即8k,会提示Not Found错误。

调用含有byte[]的方法时,内容长度大于16k时,也会出现Not Found错误。

解决方法如下:

1、wcf服务端修改web.config 如下:

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <!--注:name=随意命名,但要与service的behaviorConfiguration值对应-->
        <behavior name="AAAAA">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <!--注1:此处的name值不能随便修改,命名格式为:完全命名空间+类名 -->
      <!--注2:此处的behaviorConfiguration值要与behavior的name值对应-->
      <service name="SLFileUpload.Web.FileService" behaviorConfiguration="AAAAA" >
        <!--注1:此处的contract值不能随便修改,命名格式为:完全命名空间+接口名 -->
        <!--注2:此处的bindingConfiguration值要与binding中的name值对应-->
        <endpoint contract="SLFileUpload.Web.IFileService" binding="basicHttpBinding" bindingConfiguration="BBBBB" address="" >
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>    
      <basicHttpBinding>
        <!--name=随意命名,但要与service的bindingConfiguration值对应 -->
        <binding name="BBBBB" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
          <security mode="None"></security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

2,Silverlight端

<bindings>
     <basicHttpBinding>
        <binding name="BasicHttpBinding_IFileService" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
     </basicHttpBinding>
</bindings>

你可能感兴趣的:(Silverlight在调用wcf时传输数据过大返回Not Found的解决办法)