Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows service calling WCF service (web http configuration)
    text
    copied!<p>I've searched all the available question here, I don't know if the problem is specific to my configuration or am I missing something.</p> <p><strong>Background:</strong></p> <p>I have a WCF service hosted on IIS 7 using a HTTPS binding. The service is used to send/receive large objects. A windows service uses this WCF service to send these large objects to the it, but I get the 400 Bad Request error. I have enabled tracing in the service and the error is "the maximum message size quota for incoming messages (65536) has been exceeded". Below are the WCF and Windows service configurations and how the wcf service is utilized.</p> <p>WCF Service configuration.</p> <pre><code>&lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;globalization culture="mk-MK" fileEncoding="windows-1251" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="basicWebHttp" allowCookies="true" closeTimeout="00:59:59" receiveTimeout="00:59:59" sendTimeout="00:59:59" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" &gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;security&gt; &lt;transport clientCredentialType="None" realm="" proxyCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;serviceTimeouts transactionTimeout="00:10:00"/&gt; &lt;serviceThrottling maxConcurrentCalls="20" maxConcurrentSessions="20" maxConcurrentInstances="20" /&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="WebHttp"&gt; &lt;webHttp automaticFormatSelectionEnabled="true" faultExceptionEnabled="true" /&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;client&gt; &lt;endpoint address="" binding="webHttpBinding" bindingConfiguration="basicWebHttp" contract="Classes.IVisService" name="BasicHttpBinding_IVisService" behaviorConfiguration="WebHttp" /&gt; &lt;/client&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true" /&gt; &lt;defaultDocument&gt; &lt;files&gt; &lt;remove value="default.aspx" /&gt; &lt;remove value="iisstart.htm" /&gt; &lt;remove value="index.html" /&gt; &lt;remove value="index.htm" /&gt; &lt;remove value="Default.asp" /&gt; &lt;remove value="Default.htm" /&gt; &lt;remove value="Default.html" /&gt; &lt;add value="VisService.svc" /&gt; &lt;/files&gt; &lt;/defaultDocument&gt; &lt;urlCompression doDynamicCompression="false" /&gt; &lt;/system.webServer&gt; &lt;system.diagnostics&gt; &lt;sources&gt; &lt;source name="System.ServiceModel" switchValue="Information, ActivityTracing, Error" propagateActivity="true"&gt; &lt;listeners&gt; &lt;add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\log\Traces.svclog" /&gt; &lt;/listeners&gt; &lt;/source&gt; &lt;/sources&gt; &lt;/system.diagnostics&gt; </code></pre> <p>The service is consumed through a Windows service who has the following configuration :</p> <pre><code>&lt;system.web&gt; &lt;httpRuntime maxRequestLength="2147483647" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="basicWebHttp" allowCookies="true" closeTimeout="00:59:59" receiveTimeout="00:59:59" sendTimeout="00:59:59" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"&gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="None"&gt;&lt;/transport&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="basicWebHttpBehaviour"&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;client&gt; &lt;endpoint address="" behaviorConfiguration="basicWebHttpBehaviour" binding="webHttpBinding" bindingConfiguration="basicWebHttp" contract="labis.IVisService" name="BasicHttpBinding_IVisService" /&gt; &lt;/client&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; </code></pre> <p>The service is called like this :</p> <pre><code>System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) =&gt; { return true; }; WebChannelFactory&lt;IVisService&gt; factory = new WebChannelFactory&lt;IVisService&gt;( "BasicHttpBinding_IVisService", new Uri("https://some_ip/service.svc")); IVisService service = factory.CreateChannel(); service.PostData(large_object); </code></pre> <p>I've enabled tracing and from the log I can see that the server throws the exception : the maximum message size quota for incoming messages (65536) has been exceeded</p> <p>I think I've set all the needed properties for this to work, but no luck. Also in the IIS configuration editor I've set the system.webServer/security/requestFiltering - requestLimits property to maximum</p> <p>Any help ?</p> <p>Thanks :)</p> <p><strong>EDIT 1</strong></p> <p>I pasted the wrong endpoint configuration element. The original lacked the behaviorConfiguration="WebHttp" part but I've tested it with this property included.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload