1

我知道“HTTP 413 请求实体太大”错误是一个常见问题解答。但是我有一个变化,我已经两天无法弄清楚了。我已经创建了一个 WCF 服务端点作为本地 SharePoint 2013 应用程序的一部分(见下文)。该网站已启用 SSL,但我收到 413 错误。我已经尝试maxReceivedMessageSize根据与此错误相关的许多帖子增加站点 web.config 以及通过 IIS 管理器/站点/管理/配置编辑器修改站点本身的标志。但似乎没有任何效果。我可以毫无问题地发布小文件。我的猜测是,也许 SharePoint 做了一些事情来覆盖绑定,我需要maxReceivedMessageSize在不同的地方应用更改

服务合同

[ServiceContract]
public interface ISharepointService
{

    [OperationContract]   
    [WebInvoke(Method = "POST", UriTemplate = "UploadFile?partner={partnerid}&location={locationid}&filename={filename}&type={type}&period={period}")]   
    void UploadFile(string partnerid, string locationid, string filename, string type, string period, Stream stream);*

网络配置

<services>
  <service behaviorConfiguration="serviceBehavior" name="MyCompany.Sharepoint.MyService.SharepointServiceApp">
    <endpoint address="Sharepoint" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyCompany.Sharepoint.MyService.SharepointServiceApp"></endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding name="webBinding" maxReceivedMessageSize="2147483647">
      <security mode="Transport">
      </security>        
    </binding>
  </webHttpBinding>
</bindings>
4

3 回答 3

3

我能够通过在 SharePoint 中为我的服务创建/修改绑定来解决此问题。我通过执行以下 powershell 脚本来做到这一点:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
$contentService.ClientRequestServiceSettings.MaxReceivedMessageSize = -1
$wcfServiceSettings = New-Object Microsoft.SharePoint.Administration.SPWcfServiceSettings
$wcfServiceSettings.ReaderQuotasMaxStringContentLength = 2147483647
$wcfServiceSettings.ReaderQuotasMaxArrayLength = 2147483647
$wcfServiceSettings.ReaderQuotasMaxBytesPerRead = 2147483647
$wcfServiceSettings.MaxReceivedMessageSize = 2147483647
$wcfServiceSettings.MaxBufferSize = 2147483647
$wcfServiceSettings.ReaderQuotasMaxDepth = 2147483647
$wcfServiceSettings.ReaderQuotasMaxNameTableCharCount = 2147483647
$contentService.WcfServiceSettings["<my service name>.svc"] = $wcfServiceSettings
$contentService.Update($true)

这有效地按照原始响应者的建议进行。但它解决了 Web 服务是 SP 应用程序一部分的特殊情况的问题。

于 2016-10-17T19:02:26.360 回答
0

SylverSmyth 的灵魂对我有用。
无需创建服务工厂。
只有一个注意事项:服务的名称["<my service name>.svc"]应该是小写的。

于 2018-03-24T12:55:15.823 回答
0

还有更多必须设置的配置,尝试设置:

<system.web>
    <httpRuntime maxRequestLength="2147483647" />
</system.web>

并将其添加到您的绑定中:

<webHttpBinding>
    <binding name="webBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
       <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
       <security mode="Transport"></security>        
    </binding>
</webHttpBinding>
于 2016-10-07T22:05:49.503 回答