1

我正在尝试调用读取 XML 字符串的 WCF 服务。我收到此错误“Formater error the maximum string content length quota (8192) has been exceeded while reading XML data.” 下面是服务 web.config 文件

<?xml version="1.0"?>
<configuration>

<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug     includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IOrderCreateService"
                     maxReceivedMessageSize="2147483647"
                     openTimeout="00:1:00"
                     closeTimeout="00:1:00"
                     sendTimeout="00:25:00"
                     receiveTimeout="00:25:00">

            </binding>

        <binding name="HandleLargeMessage" maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="2147483647"
               maxStringContentLength="2147483647"
               maxArrayLength="2147483647"
               maxBytesPerRead="2147483647"
               maxNameTableCharCount="2147483647" />

        </binding>
        </basicHttpBinding>

    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>

        <!-- beta.telagententerprise.com/WcfServices-->
        <service name="OrderCreateService.OrderCreateService">
            <endpoint name="MessageServiceEndpoint"
                      address="http://localhost:2966/OrderCreateService.svc"
                      binding="basicHttpBinding"
                      bindingConfiguration="HandleLargeMessage"
                      contract="IOrderCreateService" />

        </service>

    </services>     
</system.serviceModel>

下面是客户端app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
    <behaviors>
    <serviceBehaviors>
        <behavior>
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
            <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
    </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IOrderCreateService"
                     maxReceivedMessageSize="2147483647"
                     openTimeout="00:1:00"
                     closeTimeout="00:1:00"
                     sendTimeout="00:25:00"
                     receiveTimeout="00:25:00">

            </binding>

            <binding name="HandleLargeMessage" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647"
                   maxStringContentLength="2147483647"
                   maxArrayLength="2147483647"
                   maxBytesPerRead="2147483647"
                   maxNameTableCharCount="2147483647" />

            </binding>
        </basicHttpBinding>

    </bindings>
    <client>
        <endpoint name="MessageServiceEndpoint"
                      address="http://localhost:2966/OrderCreateService.svc"
                      binding="basicHttpBinding"
                      bindingConfiguration="HandleLargeMessage"
                      contract="OrderCreateService.IOrderCreateService" />


    </client>
</system.serviceModel>

我搜索了这个错误尝试了上面的代码仍然得到 8192 错误。任何帮助都会很棒。谢谢,

4

2 回答 2

0

即使在客户端和服务器 .config 文件上设置 maxStringContentLength = "2147483647" 后,我也遇到了同样的问题。在网络上尝试了许多建议后,通过在客户端和服务器项目(在 Visual Studio 2013 中的项目属性/构建选项卡/平台目标下)匹配目标框架来修复它。

于 2015-01-31T03:53:18.297 回答
0

服务器端配置 --> 端点元素合同值不是完全限定的。应该OrderCreateService.IOrderCreateService

此外,如果您在 IIS 上托管,则到服务的地址映射由 IIS 处理。

于 2012-10-03T13:37:57.183 回答