Reducing size of xml created by serialization

Posts   
 
    
saggett
User
Posts: 50
Joined: 12-Nov-2007
# Posted on: 14-May-2008 11:36:17   

Hi

I'm looking at ways to get my Adapter .NET 3.0 WCF Application to send less xml data over the wire. Apart from the obvious (turning objectsIds off, setting fastserialization to true, making less calls, sending less entities), is there anything I should be doing?

One thing that's occurred to me is that if I didn't use such verbose names for properties and entities, the resulting xml would be much smaller, and the application would thus run faster.

Obviously I could just go and rename everything so that each entity class name and property name is as short as possible. But before I do that, is there a way of giving properties and classes an 'xml alias', i.e. "Cust" instead "Customer" when serializing to xml? If there isn't, could I request it as a feature?

Or perhaps using some sort of compression would deliver greater benefit for less effort?

Thanks, Stephen

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-May-2008 17:09:50   

In WCF, for the best performance use Custom binding to specify Binary encoding.

    <bindings>
      <customBinding>
        <binding name="NetHttpBinding">
          <reliableSession />
          <compositeDuplex />
          <oneWay />
          <binaryMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>

Please check our WCF examples.

saggett
User
Posts: 50
Joined: 12-Nov-2007
# Posted on: 15-May-2008 11:50:43   

That is true, and is something I need to explore.

But it remains the case that any reduction of the size of the xml will be helpful whatever the encoding method, as I believe that binaryMessageEncoding simply takes the xml output by LLBLGen and converts it to a binary form (as opposed to remoting where xml never enters into the equation). So coming back to my original question, do I need to resort to renaming properties to reduce the size of the xml or is there a better way to do it?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-May-2008 14:53:54   

We believe that the XML produced by Compact25 encoding is very optimized, and we can't see how it can be compacted further, maybe you can post an example of the pieces where an improvement can be made.

Another option is to use DTOs as your transefer objects rather than LLBLGen Pro objects.

saggett
User
Posts: 50
Joined: 12-Nov-2007
# Posted on: 15-May-2008 16:34:50   

Here's a example of what I'm talking about:

Instead of:

<CustomerEntity ObjectID="df7c7b33-1fd2-4fe9-b3b4-ec8d00eeebed" Format="Compact25">
    <CustomerId>CHOPS</CustomerId>
    <CompanyName>Foo Inc.</CompanyName>
    <ContactName>Yang Wang</ContactName>
    <ContactTitle>Owner</ContactTitle>
    <Address>Hauptstr. 29</Address>
    <City>Bern</City>
    <PostalCode>3012</PostalCode>
    <Country>Switserland</Country>
    <Phone>555-chang</Phone>
    <Fax>1313-chan</Fax>
    <Orders>
        <OrderEntity ObjectID="d8117794-675c-45ce-bd97-f23c22391039">
            <OrderId>10746</OrderId>
            <CustomerId>CHOPS</CustomerId>
            <EmployeeId>1</EmployeeId>
...
<cust ObjectID="df7c7b33-1fd2-4fe9-b3b4-ec8d00eeebed" Format="Compact25">
    <cid>CHOPS</cid>
    <cpname>Foo Inc.</cpname>
    <cn>Yang Wang</cn>
    <ct>Owner</ct>
    <ad>Hauptstr. 29</ad>
    <c>Bern</c>
    <pc>3012</pc>
    <co>Switserland</co>
    <p>555-chang</p>
    <f>1313-chan</f>
    <ors>
        <or ObjectID="d8117794-675c-45ce-bd97-f23c22391039">
            <oid>10746</oid>
            <cid>CHOPS</cid>
            <eid>1</eid>
...

This aliasing can be done when using WCF by use of the DataContract and DataMember attributes, I have no idea whether this would work within LLBLGen generated code however. There may be some other method of achieving the same, though.

Is there a way of using the projection framework to convert from LLBLGen Entities to DTOs (in this case Datasets I expect) and back again? I'm aware of methods to go from Entities to Dataset, but not the reverse without hand coding a custom projector for each entity.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-May-2008 10:45:56   

We think this would never work.

If that's essential for your application, maybe you need to move more features to the service so less data is transported back/forth and also perhaps compression.

(EDIT)

Also if you are looking for DTO templates, please check the following links: DTO's and WCF - My Templates Provided Template For DTO objects specifically for WCF