使用JSON而不是XML管理windows azure服务总线队列

时间:2014-03-17 09:09:28

标签: c# json azure

有没有人知道在处理windows azure服务总线REST队列时是否可以使用JSON(而不是默认的xml)?

我有一个代码示例,它将创建一个队列:

public static string CreateQueue(string queue)
{
    string token = GetToken(issuerName, issuerSecret);

    string baseAddress = GetBaseAddress();

    // Create the URI of the new queue, note that this uses the HTTPS scheme
    string queueAddress = baseAddress + queue;
    WebClient webClient = new WebClient();
    webClient.Headers["Content-Type"] = "application/atom+xml";
    webClient.Headers[HttpRequestHeader.Authorization] = token;

    // Prepare the body of the create queue request
    string putData = @"<entry xmlns=""http://www.w3.org/2005/Atom"">
                                      <title type=""text"">" + queue + @"</title>
                                      <content type=""application/xml"">
                                      <QueueDescription xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"" />
                                          </content>
                                        </entry>";

    byte[] response = webClient.UploadData(queueAddress, "PUT", Encoding.UTF8.GetBytes(putData));

    return Encoding.UTF8.GetString(response);
}

我找不到通过JSON创建队列的任何方法。

create queue xml示例并没有那么糟糕。但我必须在嵌入式客户端上实现这一点,并且像“get queue”和“list queues”这样的调用在xml中相当可怕。如果可能的话,我想把它保存在json中。

1 个答案:

答案 0 :(得分:1)

不幸的是,API只接受预定义的XML架构。对不起,我不认为你可以完成你所追求的目标。

相关问题