简体   繁体   English

如何从azure服务总线队列读取xml文件数据

[英]how to read xml file data from azure service bus queue

I just want to read XML file data that i have sent in azure service bus from queue. 我只想从队列中读取在Azure服务总线中发送的XML文件数据。 My code is 我的代码是

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> tries to deserialize the message into type T using DataContractSerializer . GetBody<T>尝试使用DataContractSerializer将消息反序列化为T类型。

What you probably want is just to read a string and then parse into XML: 您可能想要的只是读取一个string ,然后解析为XML:

var body = orderOutMsg.GetBody<string>();
XDocument orderOut = XDocument.Parse(body);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM