none
Response time Issue in WCF REST Service is very important_more 10 minutes RRS feed

  • Question

  • Hi ,

    I have created a WCF REST service to return a List of class "WsDimension",and the reponse file size is maximum 1 MB,

    My class "WsDimension":

    [DataContract]
    public class WsDimension
    {  
        [DataMember]    
        public XElement DatasRefernecesValues = new XElement("ReferenceValues");
    }

    (And in the reponse: every element has a list of Xelements ) exemple of one xelement which has a list of other xelement:

    And this is my REST service:

    [OperationContract] 
    [WebGet]     
    List<WsDimension> GetAllDimensionsByXMLFile(string xmlfile);

    And into my implementation of the code, I have three FOREACH :

    foreach (var dimension in DimensionsList)
     {
         //..
    
         foreach (var reference in ReferenceList)
         {
             //..
             foreach (var finalCharac in finalCharacsList)
    
             {
                //  Here adding a List of Xelement for every Xelement
             }
         }
     }

    And the response time is between and 10 minutes and 16 minutes,

    How to find the issue in the service implementation?Or is their any advice to fix this problem? Thanks,

    I have created a WCF REST service to return a List of class "WsDimension",and the reponse file size is maximum 1 MB,

    My class "WsDimension":

     [DataContract]
    public class WsDimension
    {  
        [DataMember]    
        public XElement DatasRefernecesValues = new XElement("ReferenceValues");
    }

    (And in the reponse: every element has a list of Xelements ) exemple of one xelement which has a list of other xelement:

    I have created a WCF REST service to return a List of class "WsDimension",and the reponse file size is maximum 1 MB,

    My class "WsDimension":

     [DataContract]
    public class WsDimension
    {  
        [DataMember]    
        public XElement DatasRefernecesValues = new XElement("ReferenceValues");
    }

    (And in the reponse: every element has a list of Xelements ) exemple of one xelement which has a list of other xelement:

    Monday, November 18, 2019 12:59 PM

All replies

  • Hi,
    The performance of the serialization is related to the performance of the CPU, memory and I/O speed.
    I don’t think the DataContractSerializer has an impact on this issue. Alternatively, we could consider the XML serializer to handle these raw xml types.
    Please refer to the below official advice.
    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/types-supported-by-the-data-contract-serializer
    Besides, Newtonsoft.json might have a better performance on serialization and deserialization. but we need to change the framework to create REST API, such as Asp.Net WebAPI. Building Rest API is not the strength of WCF, serialization performance is one of them.
    Feel free to let me know if there is anything I can help with.
    Best Regards
    Abraham
    Tuesday, November 19, 2019 2:47 AM
    Moderator
  • Thanks a lot @Abraham Qian for all the information and the clarification,
    I will see what is the best way to do the performance
    Tuesday, November 19, 2019 8:14 AM