0

我希望客户使用 RSS 阅读器订阅 Azure 服务总线上的主题。

我似乎找不到关于如何开始从服务总线动态生成提要的文档

任何人都可以给我任何指示吗?

4

1 回答 1

2

服务总线在命名空间的根目录中自行生成一个 ATOM 提要,称为“服务注册表”。它位于 https://yournamespace.servicebus.windows.net,当你去那里时很可能会显示为空浏览器。

要探索命名空间提要(ATOM 提要的嵌套结构),您需要在 HTTP GET 请求的“Authorization”或“ServiceBusAuthorization”标头中为命名空间的根提供具有“管理”访问权限的 SAS 令牌。标准的“RootManageSharedAccessKey”规则具有该权利。

    class Program
    {
        static void Main(string[] args)
        {
            // for connection string: 
            // Endpoint=sb://[[yournamespace]].servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[[key]]

             var tp = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "[[key]]");
            var token = tp.GetWebTokenAsync("http://[[yournamespace]].servicebus.windows.net/", string.Empty, true, TimeSpan.FromHours(1))
                .GetAwaiter()
                .GetResult();
            Console.WriteLine(token);
        }
    }

在控制台应用程序中使用上面的代码片段(使用 SB NuGet 包),您将获得所需的令牌字符串以放入 HTTP 标头。

当我在 HTTP“授权:”标头中使用该令牌与 Fiddler 的作曲家中的一个命名空间在根上的 HTTPS GET 时,我得到

<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Publicly Listed Services</title>
  <subtitle type="text">This is the list of publicly-listed services currently available.</subtitle>
  <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=843</id>
  <updated>2016-01-05T12:30:33Z</updated>
  <generator>Service Bus 1.1</generator>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=844</id>
    <title type="text">democtrl</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/democtrl"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=845</id>
    <title type="text">hshsjsjshjshsjhsjhs</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/hshsjsjshjshsjhsjhs"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=846</id>
    <title type="text">iotev2</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/iotev2"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=847</id>
    <title type="text">samplequeue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/samplequeue"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=848</id>
    <title type="text">stelemetryqueue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/stelemetryqueue"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=849</id>
    <title type="text">testqueue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/testqueue"/>
  </entry>
</feed>

并且在关注 testqueue 的链接时(但使用 HTTPS 来保护令牌),我得到

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>https://clemensveu.servicebus.windows.net/testqueue</id>
  <title type="text">testqueue</title>
  <published>2015-09-07T09:33:46Z</published>
  <updated>2015-09-07T09:34:17Z</updated>
  <author>
    <name>clemensveu</name>
  </author>
  <link rel="self" href="https://clemensveu.servicebus.windows.net/testqueue"/>
  <content type="application/xml">
    <QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <LockDuration>PT30S</LockDuration>
      <MaxSizeInMegabytes>16384</MaxSizeInMegabytes>
      <RequiresDuplicateDetection>false</RequiresDuplicateDetection>
      <RequiresSession>false</RequiresSession>
      <DefaultMessageTimeToLive>P14D</DefaultMessageTimeToLive>
      <DeadLetteringOnMessageExpiration>false</DeadLetteringOnMessageExpiration>
      <DuplicateDetectionHistoryTimeWindow>PT10M</DuplicateDetectionHistoryTimeWindow>
      <MaxDeliveryCount>10</MaxDeliveryCount>
      <EnableBatchedOperations>true</EnableBatchedOperations>
      <SizeInBytes>1550</SizeInBytes>
      <MessageCount>5</MessageCount>
    </QueueDescription>
  </content>
</entry>
于 2016-01-05T11:59:33.077 回答