C# WCF通信问题

C# WCF通信问题,c#,wcf,C#,Wcf,在我的WCF应用程序中,我接收到base64String格式的图像以及一些其他图像。。 为了测试我的应用程序,我创建了一个小的.aspx页面 将firstname、last name和base64字符串(图像大小:10Kb)发送到WCF服务。 我发现了错误 “格式化程序在尝试反序列化消息时引发异常: 反序列化操作“SaveData”的请求消息正文时出错。 读取XML数据时已超过最大字符串内容长度配额(8192)。 可以通过更改上的MaxStringContentLength属性来增加此配额 创建

在我的WCF应用程序中,我接收到base64String格式的图像以及一些其他图像。。 为了测试我的应用程序,我创建了一个小的.aspx页面 将firstname、last name和base64字符串(图像大小:10Kb)发送到WCF服务。 我发现了错误 “格式化程序在尝试反序列化消息时引发异常: 反序列化操作“SaveData”的请求消息正文时出错。 读取XML数据时已超过最大字符串内容长度配额(8192)。 可以通过更改上的MaxStringContentLength属性来增加此配额 创建XML读取器时使用的XmlDictionaryReaderQuotas对象。第1行,位置15301。“

如果我发送的字符串没有base64string(图像),我就能够调试wcf服务代码。 但是如果我添加Base64字符串,我会得到这个错误。 我已将所有绑定值(“maxReceivedMessageSize”)和其他值增加到最大值。 但我还是犯了这个错误。这是我的客户机和服务的web.config。 谢谢,我真的很感谢你的帮助

客户端Web.config

 <system.serviceModel>  
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IRESTService1" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:10255/RESTService1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IRESTService1" contract="ServiceReference1.IRESTService1"
        name="BasicHttpBinding_IRESTService1" />
    </client>
  </system.serviceModel>

服务web.config

<system.serviceModel>       
    <bindings>
      <basicHttpBinding>
        <binding name="BasicBinding1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>      

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service name="RESTService1">
        <endpoint address=""
          binding="basicHttpBinding" name="MainHttpPoint" contract="RESTService1"  bindingConfiguration="BasicBinding1" />       
      </service>
    </services>

    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>-->
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>   

在web.config文件中的
绑定
标记中添加这些行

<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"   maxBytesPerRead="2147483647" />
</binaryMessageEncoding>
<httpTransport  decompressionEnabled="True" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>


希望此帮助将这些行添加到web.config文件中的
Binding
标记中

<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"   maxBytesPerRead="2147483647" />
</binaryMessageEncoding>
<httpTransport  decompressionEnabled="True" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>


希望这对你有所帮助

你好,Amani,谢谢你的回复。但它不允许我在标签中添加标签。我的朋友,我说的是绑定标签,不是绑定。嗨,Amani,谢谢你的回复。但它不允许我在标签中添加标签。我的朋友,我说的是绑定标签,不是绑定。