views:

69

answers:

2

We have a some objects that are exposed by WCF services (using wsHttpBinding) and serialized into XML. Here is 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?

A: 

Hi John,

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.

Rubens Farias
Thanks for the suggestion, but my question isn't really about how to get the message. WCF tracing will do this for me, or I can even load up a DataContractSerializer, serialize into a MemoryStream and then write to disk. I'm looking for advice on analysing the captured XML.
John Rayner
A: 

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".

Alex