對不起,發佈這個,但它讓我瘋狂。我在VS2010中的WCF4 REST模板中使用路由。我將maxreceivedmessagesize屬性設置爲一個龐大的數字,當我嘗試將xml提交給服務時,它仍然給我一個HTTP狀態代碼400。我打開了跟蹤,並且該消息告訴我它仍然設置爲默認消息大小。這讓我認爲這個問題在我設置web.config的過程中存在一些細微差別。有人可以快速地看到它,讓我知道他們在想什麼嗎?什麼是WCF 4 REST服務的正確配置?
我一直都在這附近,並且額外的一雙眼睛會對我有很大的好處。提前致謝!
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" openTimeout="00:25:00" closeTimeout="00:25:00" sendTimeout="00:25:00" receiveTimeout="00:25:00" maxBufferSize="2147483647">
<readerQuotas maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="9000000"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147483647" transferMode="Streamed" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
我面臨同樣的問題。我還沒有找到解決方案。你能否更具體些?當你說「這不是序列化我試圖在http文章中提交的對象」。你到底做了什麼來修復它? – Arti