【问题标题】:WCF Service - 400 Bad Request error on dynamic proxyWCF 服务 - 动态代理上的 400 错误请求错误
【发布时间】:2016-09-01 16:30:33
【问题描述】:

我正在使用 WCF 服务并在静态 IP 上创建动态代理。 网址=“http://”+静态IP+“/CM.svc”

BasicHttpBinding 绑定 = new BasicHttpBinding();

还设置了 binding.MaxReceivedMessageSize = 2147483647; Maxbuffersize、MaxbufferPoolsize、Receivetimeout、Opentimeout、closetimeout、sendtimeout、transferMode...

EndpointAddress endpoint = new EndpointAddress(Url);
ChannelFactory<ICMOnlineApp> factory = new ChannelFactory<ICmOnlineApp>(binding, endpoint);

foreach(var operation in factory.Endpoint.Contract.Operations)
{
operation.Behaviors.find<DataContractSerializerOperationBehavior>().DataContractResolver = new DynamicTypeResolver();

 ICMOnlineApp proxy = factory.CreateChannel();

return proxy;

}

我还完成了 WCF 服务的 web.config 文件中的所有设置。

我仍然收到此错误。请指导。

【问题讨论】:

  • 您的客户实际上向服务发送了什么?你检查过电线是怎么回事吗?您可以使用 wireshark、tcpmon 或为此启用 WCF 跟踪。
  • 我正在向 web 服务发送大约 21 个参数。包括 10 个数据表、1 个数据集、1 个哈希表和其他字符串/十进制参数。我已启用 WCF 跟踪。它给了我“传入消息的最大消息大小配额(65536)已超过ec。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。
  • 你设置了客户端和服务器的属性吗?

标签: c# wcf


【解决方案1】:

对于 WCF 跟踪中显示的错误,您向其发送消息的服务不允许该大小的消息。

"The maximum message size quota for incoming messages(65536) has been exceed"

更改 WCF 服务和客户端的配置以允许该大小的消息:

<bindings>
    <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="2147483647" 
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
            <readerQuotas maxDepth="32" 
                 maxArrayLength="2147483647"
                 maxStringContentLength="2147483647"/>
        </binding>
    </basicHttpBinding>
</bindings>

【讨论】:

  • 我已经在我的 WCF web.config 文件以及动态绑定中完成了这项工作。让我知道是否有其他解决方案。
  • 您能否在 WCF 服务上显示您的配置文件以及您在动态绑定中使用的代码?
  • 请在下面找到配置文件。
【解决方案2】:

在 web.config 和类中尝试以下配置:

Web.config:

<binding name="BasicBinding" maxReceivedMessageSize="2147483647" receiveTimeout="00:01:00" sendTimeout="00:01:00"
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>

代码:

BasicHttpBinding binding = new BasicHttpBinding();
binding.MaxReceivedMessageSize = int.MaxValue;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-27
    • 2015-11-24
    • 2011-09-29
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    相关资源
    最近更新 更多