2

I'm new to OneM2M Protocol. Searching for the OneM2M TS0001 documents, I don't get any idea of determining the Notification MIME type.

How do I determine MIME type(e.g. 'application/json', 'application/xml') of notification?

I couldn't find anything in Subscription's attributes.

This is an example of application developer guide from the site below. How did they decide to send this notification as the type of 'application/xml'?


Post a notification to ADN-AE1 HTTP Request with XML payload

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

beaver
  • 17,333
  • 2
  • 40
  • 66

1 Answers1

1

You should have a look at TS-0004 "Service Layer Core Protocol Specification", section 6.7 "oneM2M specific MIME media types". There you can find all the oneM2M specific MIME types.

According to that table, the correct MIME type for a notification and XML encoding is application/vnd.onem2m-ntfy+xml.

That said, you might also check TS-0009 "HTTP Protocol Binding", sections 6.4.2 "Accept" and 6.4.3 "Content-Type". Here, the specification says, for example for 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.

Since one can determine unambiguously the type of the resource by looking at the element *m2m:sgn", setting *application/xml" as the Content-Type for XML encoded resources is usually enough.

You can download the latest versions of the oneM2M specifications at http://www.onem2m.org/technical/published-drafts

Update

The CSE determines the encoding type (xml, json or cbor) for the notification message by looking at the optional ty parameter of the notificationURI attribute.

This is specified in TS-0001, section 9.6.8 "Resource Type subscription". The subscriber of a notification can add a type parameter (e.g. ty=xml) to the notificationURI. If this is left out, then the CSE chooses a default encoding.

Andreas Kraft
  • 3,754
  • 1
  • 30
  • 39
  • Thank you. But what I want to know is the determining of Content-Type of Notification. When someone create ContentInstance for instance, I need to send Notification if there is a Subscription under the Container. NotificationURI is defined in the Subscription, but I can't find any information of the Content-Type the subscriber want. I didn't find anything in the Subscription's attributes. Is XML encoded resources enough? And sorry for my poor English. – Hyunchul Ma Jan 18 '19 at 03:48
  • You mean, how does the CSE determine the encoding type (xml, json or cbor) for the notification message? This is specified in TS-0001, section 9.6.8 "Resource Type subbscription". Look at the specification of the *notificationURI* attribute. Here it says that the subscriber of a notification can add a type parameter (ty=...) to the URI. If this is left out, then the CSE can choose a default encoding. – Andreas Kraft Jan 18 '19 at 09:08
  • `ct=(xml|json|cbor)` – Spongman Dec 29 '22 at 23:27