wiki:HTTP_Interface_Subscription

Version 1 (modified by ralphm, 5 years ago) (diff)

--

Subscription to a remote node

Registering a callback for subscribing to a (remote) node

POST /subscribe HTTP/1.1
Host: localhost:8081
Content-Type: application/json
Content-Length: 127

{"callback": "http:\/\/localhost\/callback",
 "uri": "xmpp:example.com;?node=generic\/609bbd8f-730d-4c89-be0a-02a4690176ae"}

On receiving the request, the gateway dereferences the given XMPP URI into the JID of the (remote) publish-subscribe service and NodeID to subscribe to. It then requests the publish-subscribe service to subscribe to the node, sending notifications to itself:

<iq from='example.org' to='example.com' type='set' id='s521'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <subscribe node='generic/609bbd8f-730d-4c89-be0a-02a4690176ae'
               jid='example.org'/>
  </pubsub>
</iq>

If the subscription request is accepted, the publish-subscribe service responds with the status of the subscription.

<iq from='example.com' to='example.org' type='result' id='s521'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <subscription node='generic/609bbd8f-730d-4c89-be0a-02a4690176ae'
                  jid='example.org'
                  subscription='subscribed'/>
  </pubsub>
</iq>

The gateway then responds to the HTTP client. As there is no additional information to relay back to the HTTP client, the status code is 204.

HTTP/1.1 204 No Content

Receiving notifications

<message from='example.com' to='example.org' id='n291'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='generic/609bbd8f-730d-4c89-be0a-02a4690176ae'>
      <item id='current'>
        <entry xmlns="http://www.w3.org/2005/Atom">
          <title>Havoc by Atom-Powered Robots</title>
          <id>urn:uuid:1aed3592-28f9-4381-abe2-550232e89638</id>
          <updated>2003-12-14T01:13:32Z</updated>
          <author><name>Jane Doe</name></author>
          <content>Some commentary.</content>
        </entry>
      </item>
    </items>
  </event>
</message>

Alternative 1

POST /callback HTTP/1.1
Host: localhost
Content-Type: application/atom+xml;type=entry;charset=utf-8
Content-Length: 284
PubSub-Service: example.com
PubSub-Node: generic/609bbd8f-730d-4c89-be0a-02a4690176ae
PubSub-Item: current

<entry xmlns="http://www.w3.org/2005/Atom">
  <title>Havoc by Atom-Powered Robots</title>
  <id>urn:uuid:1aed3592-28f9-4381-abe2-550232e89638</id>
  <updated>2003-12-14T01:13:32Z</updated>
  <author><name>Jane Doe</name></author>
  <content>Some commentary.</content>
</entry>

Item retraction:

POST /callback HTTP/1.1
Host: localhost
Content-Length: 0
PubSub-Service: example.com
PubSub-Node: generic/609bbd8f-730d-4c89-be0a-02a4690176ae
PubSub-Item: current
Event: retract

Node deletion:

POST /callback HTTP/1.1
Host: localhost
Content-Length: 0
PubSub-Service: example.com
PubSub-Node: generic/609bbd8f-730d-4c89-be0a-02a4690176ae
Event: delete

Alternative 2

POST /callback?service=example.com;node=generic/609bbd8f-730d-4c89-be0a-02a4690176ae;item=current HTTP/1.1
Host: localhost
Content-Type: application/atom+xml;type=entry;charset=utf-8
Content-Length: 284

<entry xmlns="http://www.w3.org/2005/Atom">
  <title>Havoc by Atom-Powered Robots</title>
  <id>urn:uuid:1aed3592-28f9-4381-abe2-550232e89638</id>
  <updated>2003-12-14T01:13:32Z</updated>
  <author><name>Jane Doe</name></author>
  <content>Some commentary.</content>
</entry>

Item retraction:

POST /callback?action=retract;service=example.com;node=generic/609bbd8f-730d-4c89-be0a-02a4690176ae;item=current HTTP/1.1
Host: localhost
Content-Length: 0

Node deletion:

POST /callback?action=retract;service=example.com;node=generic/609bbd8f-730d-4c89-be0a-02a4690176ae HTTP/1.1
Host: localhost
Content-Length: 0

Alternative 3

POST /callback HTTP/1.1
Host: localhost
Content-Type: application/xml;charset=utf-8
Content-Length: 284
PubSub-Service: example.com

<items xmlns="http://jabber.org/protocols/pubsub#event" node="generic/609bbd8f-730d-4c89-be0a-02a4690176ae">
  <item id="current">
    <entry xmlns="http://www.w3.org/2005/Atom">
      <title>Havoc by Atom-Powered Robots</title>
      <id>urn:uuid:1aed3592-28f9-4381-abe2-550232e89638</id>
      <updated>2003-12-14T01:13:32Z</updated>
      <author><name>Jane Doe</name></author>
      <content>Some commentary.</content>
    </entry>
  </item>
</items>
POST /callback HTTP/1.1
Host: localhost
Content-Type: application/xml;charset=utf-8
Content-Length: 284
PubSub-Service: example.com

<items xmlns="http://jabber.org/protocols/pubsub#event" node="generic/609bbd8f-730d-4c89-be0a-02a4690176ae">
  <retract id="current"/>
</items>
POST /callback HTTP/1.1
Host: localhost
Content-Type: application/xml;charset=utf-8
Content-Length: 284
PubSub-Service: example.com

<delete xmlns="http://jabber.org/protocols/pubsub#event" node="generic/609bbd8f-730d-4c89-be0a-02a4690176ae"/>