当一个实体被创建一个类型,然后,一个具有相同id但类型为空的实体被创建,contextbroker响应ok,但实体没有被创建。
但是如果创建的顺序相反,首先是具有空 id 的实体,然后是具有 aa 类型的实体,上下文代理响应为 ok 并列出实体。
执行案例1的脚本
#/bin/bash
HOST=localhost
SERVICE=Service123
SUBSERVICE=/Subservice123
#Create an entity with id and type
CREATE=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
-d '
{
"id": "firstID",
"type": "firstType",
"attributes": []
}')
#List the entities
LIST=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X GET \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
)
echo $CREATE
echo "**********************"
echo $LIST
#Create an entity with the same ID but different type
CREATE=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
-d '
{
"id": "firstID",
"type": "",
"attributes": []
}')
#List the entityies
LIST=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X GET \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
)
echo
echo "Second Iteration"
echo
echo $CREATE
echo "**********************"
echo $LIST
执行案例 2 的脚本
#/bin/bash
HOST=localhost
SERVICE=Service1234
SUBSERVICE=/Subservice1234
#Create an entity with id and type
CREATE=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
-d '
{
"id": "firstID",
"type": "",
"attributes": []
}')
#List the entities
LIST=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X GET \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
)
echo $CREATE
echo "**********************"
echo $LIST
#Create an entity with the same ID but different type
CREATE=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
-d '
{
"id": "firstID",
"type": "fistType",
"attributes": []
}')
#List the entityies
LIST=$(\
curl http://$HOST:1026/v1/contextEntities \
-s \
-X GET \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: $SERVICE" \
-H "Fiware-ServicePath: $SUBSERVICE" \
)
echo
echo "Second Iteration"
echo
echo $CREATE
echo "**********************"
echo $LIST