确定通知的 MIME 类型

Determining MIME type of Notification

我是 OneM2M 协议的新手。 搜索 OneM2M TS0001 文档,我不知道如何确定通知 MIME 类型。

如何确定通知的 MIME 类型(例如 'application/json'、'application/xml')?

我在订阅的属性中找不到任何内容。

这是来自以下站点的应用程序开发人员指南示例。他们是如何决定将此通知作为 'application/xml' 类型发送的?


Post 给 ADN-AE1 的通知 具有 XML 负载

的 HTTP 请求
POST / HTTP/1.1
Host: 192.168.0.10:9090
X-M2M-Origin: /mn-cse
X-M2M-RI: notif-12345
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?>
<m2m:sgn xmlns:m2m="http://www.onem2m.org/xml/protocols" rn="cin-394798749">
  <nev>
    <rep>
      <m2m:cin>
        <ty>4</ty>
        <ri>cin-394798749</ri>
        <pi>cnt-790965889</pi>
        <ct>20150925T050534</ct>
        <lt>20150925T050534</lt>
        <et>20151107T154802</et>
        <st>0</st>
        <cnf>text/plain:0</cnf>
        <cs>3</cs>
        <con>ON</con>
      </m2m:cin>
    </rep>
  </nev>
  <sur>/mn-cse/sub-856593979</sur>
</m2m:sgn>

http://www.onem2m.org/application-developer-guide/implementation/notifications

您应该看看 TS-0004 "Service Layer Core Protocol Specification",第 6.7 节 "oneM2M specific MIME media types"。您可以在那里找到所有 oneM2M 特定的 MIME 类型。

根据 table,通知的正确 MIME 类型和 XML 编码是 application/vnd.onem2m-ntfy+xml

也就是说,您还可以查看 TS-0009 "HTTP Protocol Binding"、第 6.4.2 "Accept" 节和第 6.4.3 "Content-Type" 节。在这里,规范说,例如 Content-Type:

Any HTTP request or response containing message-body shall include the Content-type header set to one of “application/xml”, “application/json”, or the oneM2M defined media types defined in clause 6.7 of oneM2M TS-0004.

由于可以通过查看元素 *m2m:sgn 明确地确定资源的类型,因此设置 *application/xml" 作为 XML 编码资源的 Content-Type 通常就足够了.

您可以在 http://www.onem2m.org/technical/published-drafts

下载最新版本的 oneM2M 规范

更新

CSE 通过查看 ty 的可选参数来确定通知消息的编码类型(xml、json 或 cbor) =29=]notificationURI 属性。

这在 TS-0001 的第 9.6.8 节中指定 "Resource Type subscription"。通知的订阅者可以将类型参数(例如 ty=xml)添加到 notificationURI。如果省略,则 CSE 会选择默认编码。