分析 XML 序列化对象图以找出占用最多空间的内容
我们有一些由 WCF 服务公开的对象(使用 wsHttpBinding)并序列化为 XML。以下是其中之一的摘录:
[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 ...
}
正如您所看到的,有许多集合,并且其中一些包含的对象下面还有更多的子对象。当我们针对生产数据运行此方法时,我们发现虽然大多数人员记录都很好,但有些记录会转换为非常大的序列化消息(例如,> 500 KB)。
现在我希望我们需要开始修剪我们的对象图,但我想找出哪些数据位对序列化消息贡献最大。例如,它是 Address
对象的列表,还是 InternationalExperience
对象中的某些数据块。
您是否知道有一种工具可以捕获和分析正在发送的 XML 消息,以便我可以找出占用最多空间的内容?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不久前,我为 CodeProject 写了一篇文章,其中描述了如何构建WCF 托管程序(不是您的问题)并实现了 IEndpointBehavior 来显示消息内容。
也许你可以尝试一下。
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.
是的,有一个工具。您可以使用 WCF 配置文件工具启用消息日志记录并检查大消息。 SvcTraceViewer 允许您分析跟踪数据。在 MSDN 中搜索“消息记录”。
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".