Hello,
I tested what you suggested to me, it works very well with the gscl.
1) In my case, I didn't use the OM2M GSCL. I tried with two network
applications which are registered at NSCL.
- LampApp and its container "LampAppToScape"
- TestReceiveFile1 and its container " TestToReceiveFile ".
2) Application TestReceiveFile1 subscribes to the container
"LampAppToScape" of the NA "LampApp".
Subscribe TestReceiveFile1 to LampApp:
POST http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/LampAppToScape/contentInstances/subscriptions
<om2m:subscription xmlns:om2m="http://uri.etsi.org/m2m">
<om2m:contact>nscl/applications/TestReceiveFile1</om2m:contact>
</om2m:subscription>
3) At the same time, when creating the application TestReceiveFile1,
I added an attribute "aPoc" :
<om2m:aPoC>http://127.0.0.1:8080/om2m/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstances</om2m:aPoC>
4) When I create an contentInstance in the container
"LampAppToScape" of the NA "LampApp", it will send a notification to
the application "TestReceiveFile1".
5) As the application "TestReceiveFile1" has an attribute
aPoc "
http://127.0.0.1:8080/om2m/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstances",
the new base uri of the notification message will be:
http://127.0.0.1:8080/om2m/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstances.
And targetID=null. The final resourceID will be the combination of
the two :
http://127.0.0.1:8080/om2m/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstancesNULL.
6) Here is the result(It's a little bit hope it won't scare you :)
)
INFO: RequestIndication [method=CREATE,
base=http://127.0.0.1:8080/om2m/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstances,
targetID=null, representation=<?xml version="1.0"
encoding="UTF-8" standalone="yes"?>
<om2m:notify xmlns:om2m="http://uri.etsi.org/m2m"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<om2m:statusCode>STATUS_CREATED</om2m:statusCode>
<om2m:representation
xmime:contentType="application/xml">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8b20ybTpjb250ZW50SW5zdGFuY2UgeG1sbnM6b20ybT0iaHR0cDovL3VyaS5ldHNpLm9yZy9tMm0iIHhtbG5zOnhtaW1lPSJodHRwOi8vd3d3LnczLm9yZy8yMDA1LzA1L3htbG1pbWUiIG9tMm06aWQ9IkNJXzQxMDY0NDg0MCIgaHJlZj0ibnNjbC9hcHBsaWNhdGlvbnMvTGFtcEFwcC9jb250YWluZXJzL0xhbXBBcHBUb1NjYXBlL2NvbnRlbnRJbnN0YW5jZXMvQ0lfNDEwNjQ0ODQwIj4KICAgIDxvbTJtOmNyZWF0aW9uVGltZT4yMDE0LTA2LTE4VDEyOjAzOjEwLjY4NiswMjowMDwvb20ybTpjcmVhdGlvblRpbWU+CiAgICA8b20ybTpsYXN0TW9kaWZpZWRUaW1lPjIwMTQtMDYtMThUMTI6MDM6MTAuNjg3KzAyOjAwPC9vbTJtOmxhc3RNb2RpZmllZFRpbWU+CiAgICA8b20ybTpkZWxheVRvbGVyYW5jZT4yMDE0LTA2LTE4VDE1OjIzOjEwLjY4NiswMjowMDwvb20ybTpkZWxheVRvbGVyYW5jZT4KICAgIDxvbTJtOmNvbnRlbnRTaXplPjQ5PC9vbTJtOmNvbnRlbnRTaXplPgogICAgPG9tMm06Y29udGVudD5QSEp2YjNRZ1ptbHNaUzEyWlhKemFXOXVQU0l4TGpZaVBqeHZjbVJsY2o1UFRqd3ZiM0prWlhJK1BDOXliMjkwUGc9PTwvb20ybTpjb250ZW50Pgo8L29tMm06Y29udGVudEluc3RhbmNlPgo=</om2m:representation>
<om2m:subscriptionReference>nscl/applications/LampApp/containers/LampAppToScape/contentInstances/subscriptions/SUB_898156220</om2m:subscriptionReference>
</om2m:notify>
, requestingEntity=admin/admin, protocol=null]
Jun 18, 2014 12:03:10 PM
org.eclipse.om2m.comm.http.RestHttpServlet service
INFO: HttpRequest [method=POST,
URI=/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstancesnull,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<om2m:notify xmlns:om2m="http://uri.etsi.org/m2m"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<om2m:statusCode>STATUS_CREATED</om2m:statusCode>
<om2m:representation
xmime:contentType="application/xml">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8b20ybTpjb250ZW50SW5zdGFuY2UgeG1sbnM6b20ybT0iaHR0cDovL3VyaS5ldHNpLm9yZy9tMm0iIHhtbG5zOnhtaW1lPSJodHRwOi8vd3d3LnczLm9yZy8yMDA1LzA1L3htbG1pbWUiIG9tMm06aWQ9IkNJXzQxMDY0NDg0MCIgaHJlZj0ibnNjbC9hcHBsaWNhdGlvbnMvTGFtcEFwcC9jb250YWluZXJzL0xhbXBBcHBUb1NjYXBlL2NvbnRlbnRJbnN0YW5jZXMvQ0lfNDEwNjQ0ODQwIj4KICAgIDxvbTJtOmNyZWF0aW9uVGltZT4yMDE0LTA2LTE4VDEyOjAzOjEwLjY4NiswMjowMDwvb20ybTpjcmVhdGlvblRpbWU+CiAgICA8b20ybTpsYXN0TW9kaWZpZWRUaW1lPjIwMTQtMDYtMThUMTI6MDM6MTAuNjg3KzAyOjAwPC9vbTJtOmxhc3RNb2RpZmllZFRpbWU+CiAgICA8b20ybTpkZWxheVRvbGVyYW5jZT4yMDE0LTA2LTE4VDE1OjIzOjEwLjY4NiswMjowMDwvb20ybTpkZWxheVRvbGVyYW5jZT4KICAgIDxvbTJtOmNvbnRlbnRTaXplPjQ5PC9vbTJtOmNvbnRlbnRTaXplPgogICAgPG9tMm06Y29udGVudD5QSEp2YjNRZ1ptbHNaUzEyWlhKemFXOXVQU0l4TGpZaVBqeHZjbVJsY2o1UFRqd3ZiM0prWlhJK1BDOXliMjkwUGc9PTwvb20ybTpjb250ZW50Pgo8L29tMm06Y29udGVudEluc3RhbmNlPgo=</om2m:representation>
<om2m:subscriptionReference>nscl/applications/LampApp/containers/LampAppToScape/contentInstances/subscriptions/SUB_898156220</om2m:subscriptionReference>
</om2m:notify>
, Authorization=Basic YWRtaW4vYWRtaW4=, queryString=null]
Jun 18, 2014 12:03:10 PM
org.eclipse.om2m.core.router.Router doRequest
INFO: RequestIndication [method=CREATE, base=null,
targetID=/nscl/applications/TestRecieveFile1/containers/TestToReceiveFile/contentInstancesnull,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<om2m:notify xmlns:om2m="http://uri.etsi.org/m2m"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<om2m:statusCode>STATUS_CREATED</om2m:statusCode>
<om2m:representation
xmime:contentType="application/xml">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8b20ybTpjb250ZW50SW5zdGFuY2UgeG1sbnM6b20ybT0iaHR0cDovL3VyaS5ldHNpLm9yZy9tMm0iIHhtbG5zOnhtaW1lPSJodHRwOi8vd3d3LnczLm9yZy8yMDA1LzA1L3htbG1pbWUiIG9tMm06aWQ9IkNJXzQxMDY0NDg0MCIgaHJlZj0ibnNjbC9hcHBsaWNhdGlvbnMvTGFtcEFwcC9jb250YWluZXJzL0xhbXBBcHBUb1NjYXBlL2NvbnRlbnRJbnN0YW5jZXMvQ0lfNDEwNjQ0ODQwIj4KICAgIDxvbTJtOmNyZWF0aW9uVGltZT4yMDE0LTA2LTE4VDEyOjAzOjEwLjY4NiswMjowMDwvb20ybTpjcmVhdGlvblRpbWU+CiAgICA8b20ybTpsYXN0TW9kaWZpZWRUaW1lPjIwMTQtMDYtMThUMTI6MDM6MTAuNjg3KzAyOjAwPC9vbTJtOmxhc3RNb2RpZmllZFRpbWU+CiAgICA8b20ybTpkZWxheVRvbGVyYW5jZT4yMDE0LTA2LTE4VDE1OjIzOjEwLjY4NiswMjowMDwvb20ybTpkZWxheVRvbGVyYW5jZT4KICAgIDxvbTJtOmNvbnRlbnRTaXplPjQ5PC9vbTJtOmNvbnRlbnRTaXplPgogICAgPG9tMm06Y29udGVudD5QSEp2YjNRZ1ptbHNaUzEyWlhKemFXOXVQU0l4TGpZaVBqeHZjbVJsY2o1UFRqd3ZiM0prWlhJK1BDOXliMjkwUGc9PTwvb20ybTpjb250ZW50Pgo8L29tMm06Y29udGVudEluc3RhbmNlPgo=</om2m:representation>
<om2m:subscriptionReference>nscl/applications/LampApp/containers/LampAppToScape/contentInstances/subscriptions/SUB_898156220</om2m:subscriptionReference>
</om2m:notify>
, requestingEntity=admin/admin, protocol=http]
Jun 18, 2014 12:03:10 PM
org.eclipse.om2m.core.router.Router doRequest
INFO: ResponseConfirm [statusCode=STATUS_BAD_REQUEST,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<om2m:additionalInfo>Bad
TargetID</om2m:additionalInfo>
</om2m:errorInfo>
, resourceURI=null]
BRs,
LIU Feifei
On 06/18/2014 05:22 AM, Mahdi Ben Alaya
wrote:
Hello,
To better understand your problem, can you test the following
scenario which includes 2 applications created on different SCL:
Preconditions:
a) Start a NSCL on 127.0.0.1:8080
b) Start a GSCL on 127.0.0.1:8181
Make sure that the GSCL and NSCL are mutually authenticated (use
the web interface).
Scenario:
1) Create SENSOR application with a DATA container on the GSCL.
2) Create MONITOR application with a DATA container on the NSCL.
3) Subscribe MONITOR to SENSOR using the following request:
POST http://127.0.0.1:8080/om2m/gscl/applications/SENSOR/containers/DATA/contentInstances/subscriptions
<om2m:subscription xmlns:om2m="http://uri.etsi.org/m2m">
<om2m:contact>nscl/applications/MONITOR/containers/DATA/contentInstances</om2m:contact>
</om2m:subscription>
4) Create a contentInstance event on the DATA container of SENSOR
application.
5) The MONITOR should receive the new event as notification on its
DATA container. Check it using the fowling request:
GET http://127.0.0.1:8080/om2m/nscl/applications/MONITOR/containers/DATA/contentInstances/latest/content
Does this scenario work for you ?
Mahdi
Le 18/06/2014 00:20, Feifei Liu a
écrit :
Hello Mr. Ben Alaya,
Thank you very much for your response. Now I understand better
about the concept of the Base URI and the Target URI.
I tried the method that you gave me, but I didn't get the
expected result. In fact, I don't understand the method:
notify(RequestIndication) in the class
Notifier(package:org.eclipse.om2m.core.notifier). In the method,
no matter which scenario it is, the target ID is set to "null".
It is here that cause the problem.
public static ResponseConfirm notify(RequestIndication
requestIndication){
if(requestIndication.
getTargetID().matches(".*://.*")){
requestIndication.setBase(requestIndication.getTargetID());
requestIndication.setTargetID(null);
return new RestClient().sendRequest(requestIndication);
}else{
String sclId = requestIndication.getTargetID().split("/")[0];
if(Constants.SCL_ID.equals(sclId)){
String appId =
requestIndication.getTargetID().split("applications/")[1];
Application application =
DAOFactory.getApplicationDAO().find(Constants.SCL_ID+"/applications/"+appId);
requestIndication.setBase(application.getAPoC());
requestIndication.setTargetID(null);
return new RestClient().sendRequest(requestIndication);
}else{
return new Redirector().retarget(requestIndication);
}
}
I put the protocol-independent URI as the contact during the
creation of the subscription : /nscl/applications/LampApp/containers/TestToReceiveFil/contentInstances.
But the destination URI of the notification message is always
a combination of the "Base URI" and the " Target URI" ,
something like: /nscl/applications/LampApp/con
tainers/TestToReceiveFil/contentInstancesNULL.
I am blocked here . Could you please help me to solve this
problem?
Thank you for your help.
Best Regards,
Feifei LIU
-------- Original Message --------
Subject: Re: OM2M-problème rencontré
Date: Sat, 14 Jun 2014 14:34:17 +0200
From: Mahdi Ben Alaya <ben.alaya@xxxxxxx>
To: LIU Feifei <feifei.liu@xxxxxxxxxxxx>
CC: ybanouar@xxxxxxx
<ybanouar@xxxxxxx>, Thierry Monteil
<monteil@xxxxxxx>
Hello Liu,
You can use our mailing list for future questions, our team
will be
happy to answer you. (subscribe here
https://dev.eclipse.org/mailman/listinfo/om2m-dev)
OM2M implements three subscription/notification scenarios: *
Scenario 1 (Your scenario)*
You should use a *protocol-independent* contact URI when you
create a
subscription for an Application:
Example:
nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances>
*(without http://127.0.0.1:8081/om2m/)*
The GSCL is able to build automatically the full URI based on
the "nscl"
stored information using the re-targeting mechanism.
Create subscription Request example:
POST
<nscl-ip>:<port>/om2m/gscl/applications/<app-id>/containers/<cont-id>/contentInstances/subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<om2m:subscription xmlns:tns="http://uri.etsi.org/m2m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
*
<**om2m:contact>nscl/applications/LampApp/containers/TestToReceiveFile
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances>****/contentInstances
<http://itpat1av77:8081/om2m/nscl/applications/APP_648263324/containers/DATA/contentInstances></**om2m:contact>*
</om2m:subscription>
To answer you question related to the "RequestIndication"
class, let's
consider the following request:
GET protocol://ip:port/context/path/to/resource
The "base" attribute contains the first part of a URI
(protocol-dependent): protocol://ip:port/context
The "targetID" attribute contains the second part of a URI
(protocol-independent) : path/to/resource
The OM2M core plugin handles protocol-independent requests to
make easy
their mapping to specific communication protocols such as HTTP
and COAP
(COAP binding will be published soon)
*Scenario 2: *
It is also possible to start an independent server (e.g.
listening on
http://192.168.0.2:1400/monitor)
and use it as contact URI for
subscription.
In that case the GSCL will send directly notification to that
specific
server.
Remarque: In this example the specific server ip should be
reachable by
the GSCL.
See this tutorial:
https://wiki.eclipse.org/OM2M/Manage_Resources#Subscribe_to_MY_SENSOR_data
*Scenario 3:*
If the specific server is not reachable by the GSCL, you can
add the
specific listening address as "aPoc" on the subscribed
application
representation like this:
Create application Request example:
POST <nscl-ip>:<port>/om2m/nscl/applications
<om2m:application xmlns:om2m="http://uri.etsi.org/m2m"
appId="appTest">
*<om2m:aPoC>http://192.168.0.2:6060/monitor</om2m:aPoC>*
</om2m:application>
Then, you can create a subscription with the URI of the
application as
contact URI (the application URI is protocol-independent). In
that case
The GSCL is able to re-target notifications to the right NSCL.
Finally
the NSCL will notify the specific listening server based on
the aPoC tag.
Create subscription Request example:
POST
<nscl-ip>:<port>/om2m/gscl/applications/<app-id>/containers/<cont-id>/contentInstances/subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<om2m:subscription xmlns:tns="http://uri.etsi.org/m2m"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
* <**om2m:contact>**nscl/applications/**appTest**</tns:**om2m>*
</om2m:subscription>
Don't hesitate to contact us if you have any question or
remark.
Best regard,
-Mahdi
Le 13/06/2014 19:20, LIU Feifei a écrit :
Bonjour Messieurs,
Je travaille actuellement au sein de Sagemcom et je suis en
train de
utiliser votre open source OM2M. Pendant l'utilisation, j'ai
rencontré
un problème sur le plateforme NSCL.
Contexte: Une application NA qui est enregistré auprès de
nsclBase.
Deux containers dans cette application sont créés. Container
1 est
pour déposer le fichier XML sur le serveur. Container 2 est
pour
tester le suscription. Il est un « subscriber » de container
1. Quand
je créée une containerInstance pour container 1, container 1
va
envoyer une notification au container 2 avec la destination
défini
dans le "contact" de suscription. Ici, j'ai
mis:*http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*pour
tester.*
*
voici le résultat:
1. INFO: Notification Request:
RequestIndication
[method=CREATE,*base=null*,*targetID=http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*,representation=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>
2. INFO: RequestIndication
[method=CREATE,*base=http://127.0.0.1:8080/om2m/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstances*,*targetID=null*,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
Jun 13, 2014 6:46:29 PM org.eclipse.om2m.comm.http.RestHttpServlet
service
3. INFO: HttpRequest
[method=POST,*URI=/nscl/applications/LampApp/containers/TestToReceiveFile/contentInstancesnull*,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
4. INFO: ResponseConfirm [statusCode=STATUS_BAD_REQUEST,
representation=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<om2m:errorInfo xmlns:om2m="http://uri.etsi.org/m2m"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<om2m:statusCode>STATUS_BAD_REQUEST</om2m:statusCode>
<om2m:additionalInfo>Bad
TargetID</om2m:additionalInfo>
</om2m:errorInfo>
, resourceURI=null]
Dans INFO 3, le URI est une combinaison de "Base" et "
Target ID",
comme le Target ID est "Null", le URI n'est pas pareil avec
le contact
dans le item "subscription".
Dans INFO 4, le server NSCL retourne un résultat "Bad
Target ID".
En fait, je ne comprends pas bien l'attribut "Base" /**
Request base
uri */ dans le class
RequestIndication(paquet:org.eclipse.om2m.commons.rest).
Je n'ai pas
trouvé non plus où cet attribut est donné la valeur dans le
class
RestHttpServlet ( paquet: org.eclipse.om2m.comm.http).
Est-ce que vous
pouvez m’aider à résoudre ce problème ?
Je vous remercie beaucoup par avance.
Cordialement,
LIU Feifei
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractè privéS'ils ne vous sont
pas destiné nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
soit le contenu. Si ce message vous a é transmis par erreur, merci d'en
informer l'expéteur et de supprimer imméatement de votre systè
informatique ce courriel ainsi que tous les documents qui y sont attaché"
******
" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractè privéS'ils ne vous sont
pas destiné nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
soit le contenu. Si ce message vous a é transmis par erreur, merci d'en
informer l'expéteur et de supprimer imméatement de votre systè
informatique ce courriel ainsi que tous les documents qui y sont attaché"
******
" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#
|