开发者

Analysing an XML serialized object graph to find out what takes up most space

We have a some objects that are exposed by WCF services (using wsHttpBinding) and serialized into XML. Here i开发者_开发技巧s an extract of one of them:

[DataContract]
public class Person
{
    [DataMember] private string _forename;
    [DataMember] private string _middleInitial;
    [DataMember] private string _surname;
    [DataMember] private List<EducationRecord> _educationRecords;
    [DataMember] private List<Address> _addresses;
    [DataMember] private List<InternetAddress> _internetAddresses;
    [DataMember] private List<PhoneNumber> _phoneNumbers;
    [DataMember] private List<InternationalExperience> _internationalExperience;
    [DataMember] private List<ProfessionalQualification> _professionalQualifications;
    [DataMember] private List<KnownLanguage> _knownLanguages;

    // And there's more ...

}

As you can see, there are many collections and some of the contained objects have further child objects beneath them. When we run this up against our production data, we find that while most Person records are fine, there are some which translate into very large serialized messages (>500 KB, for example).

Now I expect that we'll need to start pruning our object graph, but I'd like to find out which bits of data are contributing the most to the serialized message. For instance, is it the list of Address objects, or is it some chunk of data within the InternationalExperience objects.

Do you know of a tool that will capture and analyze the XML messages that are being sent, so that I can find out what is taking up the most space?


some time ago I wrote an article for CodeProject where I describe how to build a WCF hoster (not your problem) and implemented an IEndpointBehavior to display message content.

Maybe you can give it a try.


Yes, there is a tool. You can enable message logging usin the WCF config file tool and inspect the large messages. SvcTraceViewer allows you to analyze the trace data. Search MSDN for "Message Logging".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜