如何从 Azure 服务总线队列中读取 xml 文件数据
how to read xml file data from azure service bus queue
我只想读取 XML 我从队列发送到 Azure 服务总线的文件数据。我的密码是
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();
}
}
GetBody<T>
尝试使用 DataContractSerializer
.
将消息反序列化为类型 T
您可能想要的只是读取 string
然后解析为 XML:
var body = orderOutMsg.GetBody<string>();
XDocument orderOut = XDocument.Parse(body);
我只想读取 XML 我从队列发送到 Azure 服务总线的文件数据。我的密码是
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();
}
}
GetBody<T>
尝试使用 DataContractSerializer
.
T
您可能想要的只是读取 string
然后解析为 XML:
var body = orderOutMsg.GetBody<string>();
XDocument orderOut = XDocument.Parse(body);