简体   繁体   中英

WCF Service - 400 Bad Request error on dynamic proxy

I am using WCF service with dynamic proxy creation on static IP. Url = "http://" + staticIP + "/CM.svc"

BasicHttpBinding binding = new BasicHttpBinding();

Also have set 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;

}

Also i have done all settings in web.config file of WCF service.

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.

"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:

<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:

<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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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