WCF 4 REST 服务的正确配置是什么? [英] What is the proper configuration for a WCF 4 REST service?

查看:28
本文介绍了WCF 4 REST 服务的正确配置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉发布这个,但它让我发疯.我在 VS2010 的 WCF4 REST 模板中使用路由.我将 maxreceivedmessagesize 属性设置为某个庞大的数字,当我尝试向服务提交 xml 时,它仍然给我一个 HTTP 状态代码 400.我打开了跟踪,消息告诉我它仍然设置为默认消息大小.这让我认为问题在于我如何设置 web.config 的一些细微差别.有人可以快速了解一下并告诉我他们的想法吗?

Sorry to post about this, but it's driving me nuts. I am using routes in the WCF4 REST template in VS2010. I set the maxreceivedmessagesize property to some gargantuan number, and it still gives me an HTTP status code 400 when I try to submit xml to the service. I turned on tracing, and the message tells me that it's still set to the default message size. This makes me think that the problem is some nuance in how I have my web.config set up. Could somebody take a quick peak at it and let me know what they think?

我一直在处理这个问题,多一双眼睛对我大有裨益.提前致谢!

I've been around and around with this, and an extra set of eyes would be of great benefit to me. Thanks in advance!

<?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 帖子中提交的对象.当我根据测试服务器上的服务检查它时,我更正了帖子的 xml,现在它可以正常工作了.谢谢!

OK, I figured it out; the problem was actually on the client. It wasn't serializing the object that I was trying to submit in the http post. When I checked it against a service on the test server, I corrected the xml for the post and now it's working properly. Thanks!

这篇关于WCF 4 REST 服务的正确配置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆