我正在調用WCF服務的一種方法。該方法將圖像內的圖形傳遞給服務。帶有大量消息的WCF呼叫服務
所有來電拋出異常的說法:
The remote server returned an unexpected response: (400) Bad Request
我已閱讀關於這個問題的帖子很多,他們大多建議提高maxReceivedMessageSize。我試圖修改這個和其他設置,但它不能解決問題。
最後我已經激活服務器跟蹤它說:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
在我的配置文件中的值設置爲65536000.
我的配置文件:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Verbose,ActivityTracing"
propagateActivity="false">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\Trace\messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\Trace\tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<behaviors>
<endpointBehaviors>
<behavior name="Beh">
<dataContractSerializer maxItemsInObjectGraph="10000000"/>
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="WebBinding" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferSize="65536000" maxBufferPoolSize="524288000"
maxReceivedMessageSize="65536000">
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000"
maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfService1.PleasureKraftService">
<clear />
<endpoint behaviorConfiguration="Beh" binding="webHttpBinding"
bindingConfiguration="WebBinding" name="Basic" contract="WcfService1.IMyService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="WcfService1.IMyService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<compilation debug="false"/>
<customErrors mode="Off"/>
</system.web>
<connectionStrings>
<add name="Ent" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=xxxxxx;Initial Catalog=Eu;User ID=xxxxx;Password=xxxxx;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
</configuration>
我不知道如何解決你最後的問題智者。我們在公司使用不同的綁定,並在我們的'httpTransport'上設置'max ... Size'屬性。我已經刪除了我的答案,因此您的問題會得到更多的關注,因爲沒有答案。 – dasblinkenlight 2012-01-06 18:48:38
我認爲WCF不會因爲某種原因閱讀我的綁定配置,而是將默認的配置放置在它的位置。感謝您的嘗試。 – Jakub 2012-01-06 19:07:02