很抱歉发布这个,但它让我疯了。我在VS2010的WCF4 REST模板中使用路由。我将maxreceivedmessagesize属性设置为一些庞大的数字,当我尝试将xml提交给服务时,它仍然给我一个HTTP状态代码400。我打开了跟踪,消息告诉我它仍然设置为默认消息大小。这让我觉得问题是我如何设置web.config的一些细微差别。有人可以快速达到目标并让我知道他们的想法吗?
我一直在身边,而额外的一双眼睛对我来说是非常有益的。提前谢谢!
<?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>
答案 0 :(得分:0)
您的OperationContract属性是什么样的? 您是否将RequestFormat和ResponseFormat设置为WebMessageFormat.Xml? 此外,您的BodyStyle应该是WebMessageBodyStyle.WrappedRequest
由于没有条目,我假设您在IIS下运行它。 如果是这种情况,请确保您有正确配置的.svc文件。
另外,您可以检查global.asax以确保url实际指向wcf服务。我只是猜测,但有一件事我确定它不是消息大小属性
答案 1 :(得分:0)