I'm currently upgrading from NServiceBus 4.7.5 to NServiceBus 5.2.4, and when using the XmlSerializer, I noticed that it generates an invalid XML message when I try to serialize a message - the namespaces for the simple types are no longer declared, but they're still used in the document.
For example, if I try to serialize a message that exposes a SerializedPair property that is defined as follows:
public class SerializedPair
{
public string Key { get; set; }
public object Value { get; set; }
}
in 4.7.5 it would be serialized as:
<?xml version="1.0"?>
<Messages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://tempuri.net/xxx.Crm.ServiceBusMessages"
xmlns:guid="Guid" xmlns:int32="Int32"
xmlns:string="String"
xmlns:datetime="DateTime"
xmlns:boolean="Boolean"
xmlns:decimal="Decimal">
<UpdateContact>
<SerializedPair>
<Key>AddressId</Key>
<guid:Value>ebdeeb33-baa7-4100-b1aa-eb4d6816fd3d</guid:Value>
</SerializedPair>
....
In 5.2.4, it gets serialized as:
<?xml version="1.0" ?>
<UpdateContact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://tempuri.net/xxx.Crm.ServiceBusMessages">
<SerializedPair>
<Key>AddressId</Key>
<guid:Value>70a22cd7-64fd-4d6d-ab13-2ad7800addc7</guid:Value>
</SerializedPair>
....
Note that the "Messages" element is no longer present, and the "xmlns:guid" namespace declaration is also missing, which makes this invalid XML. How do I get NServiceBus to generate valid xml again?
For completeness, my BusConfiguration looks like:
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.UseSerialization<XmlSerializer>();
busConfiguration.UseTransport<MsmqTransport>();
ISendOnlyBus bus = Bus.CreateSendOnly(busConfiguration);