0

I have a .Net WebService and a standalone application written in DelphiXE2.

When I submit a list with lots of items (400) the FindAllEntity() method is very slow.

I researched compressing the data components of a list, but I only found Gzip C#, which is used for compressing files and image.

Is there a way to compress a list of data that can be sent quickly to the standalone application?

Here's the code:

//MyRegularNewEntity
    public class _MyEntity
    {
        public decimal id { get; set; }
        public _otherEntity Customers { get; set; }
        public string serial { get; set; }
        public decimal cost { get; set; }
    }

    //My Controller
    public IQueryable<c#ModelEntity> GetAllDatOfEntity()
    {

        IQueryable<C#ModelEntity> Dat;
        //The containt of data base entity is save in Dat ListQueryable
        Dat = db.MyEntity;

        return Dat;           
    }

    //My WebService
    [WebMethod]
    public List<_MyRegularEntity> FindAllEntity()
    {
        //Construct my repository
        MyRepository ag = new MyRepository();
        //Asign the result in a variable of call to get all the dat
        var Dat = ag. GetAllDatOfEntity();
        //Contruct the List with my entity to send for my client
        List<_MyRegularEntity> list = new List<_MyRegularEntity>();
        //Add all dat element to my list
        if (Dat != null)
        {
            foreach (var item in Dat)
            {
               var MyEntity = new _MyRegularEntity();
               MyEntity.id = item.id,
               MyEntity.Custormers = new _otherEntity()
               {
                   id=item.Customers.id,
                   firstname=item.Customers.firstname,
                   lastname=item.Custormers,lastname
               },
               MyEntity.Serial = item.Serial,
               MyEntity.Cost = item.Cost

               list.Add(MyEntity);
            };

         }
        //THIS IS THE RESULT I NEED COMPRESS
        return list;
    }
NotMe
  • 87,343
  • 27
  • 171
  • 245
Leo
  • 1
  • 1
    Were you aware that ASMX web services are a legacy technology and shouldn't be used for new development? WCF should be used for new development. – John Saunders Feb 10 '12 at 22:04
  • I disagree... Not on the ASMX part, you shouldn't do that. Rather, we've found that generic handlers (.ashx) are much much better than wrestling with WCF. – NotMe Feb 10 '12 at 22:32

1 Answers1

0

Gzip compression can be turned on at the server level in IIS or through your web.config file. It is used not just for transferring "files" but really for transferring anything between the client and server.

However, you should profile the web service to see if it's actually the transferring of data that is slow or if there is something else inside of your FindAllEntity() method that is slow.

Community
  • 1
  • 1
NotMe
  • 87,343
  • 27
  • 171
  • 245
  • I calculated the time of process with flags, the result is good, in the controllers the flag of my query mark 0,0000002seg, in the asmx mark 0,0000402seg, but when in the client application mark the function ws:=GetSoapService();FindAllItems(); this process mark 0,4 seg, and i guess is the compression of list data the problem. You know about the configuration of the GZip service, this is in the WebConfig or IIS, i some tutorials, using System.IO and System.IO compression but only show how to compress image. I not are expert of c# maybe need put the list in array of byte, i have a idea but. – Leo Feb 11 '12 at 00:40