简体   繁体   English

WCF 服务 - 动态代理上的 400 错误请求错误

[英]WCF Service - 400 Bad Request error on dynamic proxy

I am using WCF service with dynamic proxy creation on static IP.我在静态 IP 上使用 WCF 服务和动态代理创建。 Url = "http://" + staticIP + "/CM.svc"网址 = "http://" + staticIP + "/CM.svc"

BasicHttpBinding binding = new BasicHttpBinding(); BasicHttpBinding binding = new BasicHttpBinding();

Also have set binding.MaxReceivedMessageSize = 2147483647;也有设置 binding.MaxReceivedMessageSize = 2147483647; Maxbuffersize, MaxbufferPoolsize, Receivetimeout, Opentimeout, closetimeout, sendtimeout, transferMode... 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;

}

Also i have done all settings in web.config file of WCF service.此外,我已经在 WCF 服务的 web.config 文件中完成了所有设置。

Still i am getting this error.我仍然收到此错误。 Please guide.请指导。

For the error shown in the WCF traces looks like the service you are sending the message to doesn't allow that size of message.对于 WCF 跟踪中显示的错误,您将消息发送到的服务似乎不允许该消息大小。

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

Change the configuration of the WCF service, and the client, to allow messages of that size:更改 WCF 服务和客户端的配置,以允许该大小的消息:

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

Try with the following configuration in the web.config and in the class:尝试在 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>

Code:代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM