Serializing a DataContract class to an XML string  Sometimes
during development I want to have a light-weight approach to
logging request and response messages without setting up WCF
tracing.​ Regardless of how I am logging (Trace, EntLib,
whatever), I need to get a printable version of the data
message.  I always recommend treating DataContract classes
strictly as data transfer objects (DTO), that is they exist
purely for describing the shape of the message on the wire. That
means I don’t add any fancy constructors or business logic of
any kind to the DTOs. This maintains a separation of concerns.
However, all CLR types do have a ToString method, so I an fine
with putting it to better use than telling me the name of the
type.  In the sample code, CreateSecretRequest overrides
ToString using a static helper method, Helper.ToXmlString. That
helper method wraps an XmlSerializer and a StringWriter together
to serialize the DTO to a string of XML that I can log. All
DataContract classes can use the same ToXmlStri