我只想读取我从队列中发送到azure服务总线的XML文件数据。我的代码是
while (client.Peek() != null)
{
BrokeredMessage orderOutMsg = client.Receive();
if (orderOutMsg != null)
{
// Deserialize the message body to a pizza order.
XDocument orderOut = orderOutMsg.GetBody<XDocument>();
Console.WriteLine("Received order, {0} {1} ", orderOut.Root.Element("Customer").Element("Location_Code").Value, orderOut.Root.Element("Customer").Element("Phone_Number").Value);
orderOutMsg.Complete();
}
}
答案 0 :(得分:2)
GetBody<T>
尝试使用T
将邮件反序列化为DataContractSerializer
类型。
您可能想要的只是阅读string
然后解析为XML:
var body = orderOutMsg.GetBody<string>();
XDocument orderOut = XDocument.Parse(body);