The sample below express how to interact with messages that are sent using WindowsAzure.ServiceBus and received using Azure.Messaging.Service. To serialize the BrokeredMessage body the WindowsAzure.ServiceBus uses DataContractSerializer. Which helps in working with this library, below steps are required in sending messages through WindowsAzure.ServiceBus.
ServiceBusReceiver receiver = client.CreateReceiver(queueName);
ServiceBusReceivedMessage received = await receiver.ReceiveMessageAsync();
// Similar to the send scenario, we still rely on the DataContractSerializer and we use string as our type because we are expecting a JSON
// message body.
var deserializer = new DataContractSerializer(typeof(string));
XmlDictionaryReader reader =
XmlDictionaryReader.CreateBinaryReader(received.Body.ToStream(), XmlDictionaryReaderQuotas.Max);
// deserialize the XML envelope into a string
string receivedJson = (string) deserializer.ReadObject(reader);
// deserialize the JSON string into TestModel
TestModel output = JsonSerializer.Deserialize<TestModel>(receivedJson);
For more information check ServiceBus link.