title | summary | redirects | related | ||
---|---|---|---|---|---|
Xml Serializer |
A custom written XML serializer. |
|
|
A custom written XML serializer.
snippet: XmlSerialization
In certain integration scenarios you might want to bypass NServiceBus opinionated serialization format (essentially key/value pairs) and directly send custom XML structures over messaging. In order to do that you can simply declare one or multiple properties on the message contract as XDocument
or XElement
.
snippet: MessageWithXDocument
snippet: MessageWithXElement
The caveat of this approach is that the serializer will wrap the data in an outer node being named after the name of the property. So in the examples above you can see the associated expected payloads.
If you would like to avoid that for interoperability reasons you need to instruct the serializer to not wrap raw xml structures like the following
snippet: ConfigureRawXmlSerialization
INFO: The name of the property on the message must exactly match the name of the root node in the xml structure in order to be able to correctly deserialize the no longer wrapped content.
The XML serializer in NServiceBus is a custom implementation. As such it does not support the standard .NET XML Attributes.