none
How can we transfer the large data with WCF REST service? RRS feed

  • Question


  • I have a WCF REST service which takes complex object as input as given below

    [OperationContract()]
    [WebInvoke(UriTemplate = "/PublishDoc",Method = "POST")]
    public String PublishDoc(PubDocument objItem) ;


    [DataContract(NameSpace="")]
    class PubDocument
      {
      [DataMember]
      public int Id {get;set;}
    
      [DataMember]
      public string Name {get;set;}
    
      [DataMember]
      public Byte[] UploadDocument {get;set;}    
    }
    

    As per the Business Rule this property UploadDocument Max Size is 500
     MB . When I consume this REST service , the PubDocument object is
    serialized to JSON for JSON content type the system is taking long time
    and some times system is hanging.

    I have made the below configurations for WCF REST

    <bindings>
          <webHttpBinding>
            <binding name="webHttpBindingConfig" receiveTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true"
                     transferMode="Streamed">
              <security mode="Transport">          
              </security>
              <readerQuotas maxDepth="2147483647"
                            maxStringContentLength="2147483647"
                            maxArrayLength="2147483647"
                            maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />
            </binding>
          </webHttpBinding>
        </bindings>
    

     <endpointBehaviors>
            <behavior name="web">
              <webHttp defaultBodyStyle="Wrapped" automaticFormatSelectionEnabled="true" ></webHttp>
            </behavior>
          </endpointBehaviors>

    Questions :
    1.Is there any best technique to transfer the Large data with WCF REST
    ?
    2.Does the above process is correct way of Interoperability for JSON
    or XML inputs ?

    Tuesday, June 10, 2014 11:38 AM

Answers

  • 1.Is there any best technique to transfer the Large data with WCF REST?

    As you want to transfer large data you should transfer it Asynchronously or using threads so that your UI doesn't get hang.

    You can use WebClient or HttpWebRequest/HttpWebResponse to upload file.

    http://boomtobim.blogspot.in/2012/04/how-to-upload-filevia-wcf-rest.html


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor

    Tuesday, June 10, 2014 7:13 PM
  • Hi,

    If you want to transfer the large data with WCF REST service, then first we should configure the binding as what you did. After that please try to check that you have already used the binding configuration in the endpoint as following:

    <endpoint address=".."
                    binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig"
                    behaviorConfiguration="web" contract="..." name="..." />

    Here is an example about uploading large data in WCF Rest Service, please try to refer to:

    #How to upload a file via WCF REST Service using webHttpBinding:
    http://boomtobim.blogspot.in/2012/04/how-to-upload-filevia-wcf-rest.html .

    Also if you want to use the JSON, then your webinvoke will look like this:

    [WebInvoke(UriTemplate = "/PublishDoc",Method = "POST",
    RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json)]

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, June 11, 2014 3:03 AM
    Moderator

All replies

  • 1.Is there any best technique to transfer the Large data with WCF REST?

    As you want to transfer large data you should transfer it Asynchronously or using threads so that your UI doesn't get hang.

    You can use WebClient or HttpWebRequest/HttpWebResponse to upload file.

    http://boomtobim.blogspot.in/2012/04/how-to-upload-filevia-wcf-rest.html


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor

    Tuesday, June 10, 2014 7:13 PM
  • Hi,

    If you want to transfer the large data with WCF REST service, then first we should configure the binding as what you did. After that please try to check that you have already used the binding configuration in the endpoint as following:

    <endpoint address=".."
                    binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig"
                    behaviorConfiguration="web" contract="..." name="..." />

    Here is an example about uploading large data in WCF Rest Service, please try to refer to:

    #How to upload a file via WCF REST Service using webHttpBinding:
    http://boomtobim.blogspot.in/2012/04/how-to-upload-filevia-wcf-rest.html .

    Also if you want to use the JSON, then your webinvoke will look like this:

    [WebInvoke(UriTemplate = "/PublishDoc",Method = "POST",
    RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json)]

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, June 11, 2014 3:03 AM
    Moderator