HTTP 413错误发布到SharePoint Web服务

时间:2016-10-07 19:54:20

标签: wcf sharepoint http-status-code-413

我知道" HTTP 413请求实体太大"错误是常见问题。但是我有一个变化,我现在已经两天都无法弄明白了。我已经创建了一个WCF服务端点作为本地SharePoint 2013应用程序的一部分(见下文)。该网站启用了SSL,我收到413错误。我已尝试在网站web.config中按照与此错误相关的许多帖子增加maxReceivedMessageSize,并通过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);*

web.config

<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>

3 个答案:

答案 0 :(得分:1)

我能够通过在SharePoint中创建/修改我的服务绑定来解决这个问题。我通过执行以下powershell脚本来完成此操作:

if (!context.Roles.Any(r => r.Name == "Admin"))
{
    var store = new RoleStore<IdentityRole>(context);
    var manager = new RoleManager<IdentityRole>(store);
    var role = new IdentityRole { Name = "Admin" };

    manager.Create(role);
}

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

答案 1 :(得分: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>

答案 2 :(得分:0)

SylverSmyth的灵魂对我有用 没有创建服务工厂 只有一个注释:["<my service name>.svc"]中的服务名称应为小写。