none
Custom WCF Service and MaxReceivedMessageSize RRS feed

  • Question

  • I deployed a custom WCF REST service (a file uploader) into ISAPI folder. I am able to call this service successfully using jQuery client. I followed this article to develop WCF service: https://social.technet.microsoft.com/wiki/contents/articles/24194.sharepoint-2013-create-a-custom-wcf-rest-service-hosted-in-sharepoint-and-deployed-in-a-wsp.aspx

    Issue is that WCF service is unable to accept any files over 64KB.

    I understand that I need to increase MaxReceivedMessageSize property for this service. However, I am confused as to in which web.config I need to make this change. I see a web.config in ISAPI folder or do I need to create a new web.config? If I scroll through ISAPI web.config, I do not see any endpoint for the WCF service.

    Here is the svc file:

    <%@ ServiceHost Language="C#" Debug="true"
        Service="FileUpload.ISAPI.UploadService, $SharePoint.Project.AssemblyFullName$"
        CodeBehind="UploadService.svc.cs"
        Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory,
        Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral,
        PublicKeyToken=71e9bce111e9429c" %>

    Any pointers?


    • Edited by diffident Friday, May 24, 2019 8:17 PM
    Friday, May 24, 2019 8:15 PM

Answers

  • Thanks, Lee. I ended up doing a combination of several changes.

    1. Modified factory attribute of SVC file from MultipleBaseAddressWebServiceHostFactory to System.ServiceModel.Activation.WebServiceHostFactory and moved WCF service to a new folder under ISAPI and created a dedicated web.config.

    2. Modified maxReceivedMessageSize in the binding element and added readerQuotas element with maxBytesPerRead in the server-side web.config. Also added httpRunTime element with maxRequestLength property.

    3. Modified client web.config to include maxReceivedMessageSize. No readerQuotas was required.

    Hope this helps someone!

    • Marked as answer by diffident Tuesday, May 28, 2019 8:49 PM
    Tuesday, May 28, 2019 8:49 PM

All replies