WCF SOAP 服务对于大型请求返回 Not Found,对于较小的请求工作正常

标签 wcf silverlight ssl soap https

我有一个 SilverLight 应用程序,它通过 SSL 通过 POST 调用 WCF 服务并发送大请求。使用自签名证书在本地机器上一切正常。此外,它可以在远程服务器上运行,但仅用于小请求。当应用程序为大范围数据发出 POST 请求(使用 SOAP)时,我收到 CommunicationException:“远程服务器返回错误:NotFound。”使用完全相同的 web.config 文件(sql 连接字符串除外)的本地计算机上的相同用例可以正常工作。看来是IIS配置的问题。我试图调查 IIS 日志,但在日志记录内核拒绝请求之前没有找到任何关于请求的信息。我读过很多文章,其中人们提出了端点绑定(bind)的不同设置,尝试过但没有取得成功。 我的服务配置如下:

<system.web>
    <httpRuntime maxRequestLength="2097151"/>
    <!--...(other settings) -->
</system.web>

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483647" />
        </requestFiltering>
    </security>
</system.webServer> 

<system.serviceModel>
    <services>
        <!--... (other services)-->
        <service name="SD.Web.Services.ClientUser.UserLayersService">
            <endpoint address="soap" 
                      binding="basicHttpBinding" 
                      contract="SD.Web.Services.ClientUser.IUserLayersService" />

            <endpoint address="json" 
                      behaviorConfiguration="SD.Web.Services.AspNetAjaxBehavior" 
                      binding="webHttpBinding" 
                      contract="SD.Web.Services.ClientUser.IUserLayersService" />

            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
        </service>
    </services>

    <bindings>
        <webHttpBinding>
            <binding maxReceivedMessageSize="2097152"
                     maxBufferSize="2097152"
                     maxBufferPoolSize="2097152">
                <security mode="Transport" />
            </binding>
        </webHttpBinding>
        <basicHttpBinding>
            <binding maxReceivedMessageSize="2097152"
                     maxBufferSize="2097152"
                     maxBufferPoolSize="2097152">
                <security mode="Transport" />
            </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="SD.Web.Services.AspNetAjaxBehavior">
          <webHttp  defaultBodyStyle="Bare" 
                    defaultOutgoingResponseFormat="Json" 
                    automaticFormatSelectionEnabled="false" 
                    faultExceptionEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

最佳答案

我使用 Fiddler 4 找到了答案。必须设置读者配额。

<bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="2097152"
                 maxBufferSize="2097152"
                 maxBufferPoolSize="2097152">
          <readerQuotas maxDepth="2147483647" 
                        maxStringContentLength="2147483647" 
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2097152"
                 maxBufferSize="2097152"
                 maxBufferPoolSize="2097152">
          <readerQuotas maxDepth="2147483647" 
                        maxStringContentLength="2147483647" 
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>

关于WCF SOAP 服务对于大型请求返回 Not Found,对于较小的请求工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31810415/

相关文章:

c# - 这个用于连接和声明事件的 C# 代码的 VB.NET 等价物是什么?

ssl - 我可以检测浏览器支持的 SSL 版本吗?

http - Cloudflare 页面规则,仅在一页上使用 SSL

database - 没有属性的 WCF 服务返回对象

wcf - WCF 的 BasichttpBinding vs WSHttpBinding

c# - 使用 WCF 发现跨域发现非 WCF Windows 服务

silverlight - Webbrowser 控件和查询字符串 WP7

silverlight - 如何使用 silverlight 在文本框中创建水印?

PHP - 如何从 shell_exec 输出中获取参数

c# - WCF SSL 负载均衡器。负载均衡器更改 ssl 端口