我是否需要任何代理,以使FIWARE Orion Context Broker可以看到Context Provider?

时间:2018-12-06 15:35:16

标签: docker fiware fiware-orion

我无法从docker安装的Orion Context Broker中从注册的Context Provider获取属性。我是否还需要其他东西(例如特殊上下文代理?)


设置

按照以下命令,我已经完成了整个Orion Context Broker的所有设置和运行:

=MID(A2,SEARCH("HCE",A2),9)

实体

我还通过运行以下命令添加了一个商店实体(来自https://github.com/Fiware/tutorials.Getting-Started教程):

docker pull mongo:3.6
docker pull fiware/orion
docker network create fiware_default

docker run -d --name=mongo-db --network=fiware_default \
  --expose=27017 mongo:3.6 --bind_ip_all --smallfiles
docker run -d --name fiware-orion -h orion --network=fiware_default \
  -p 1026:1026  fiware/orion -dbhost mongo-db

此外,我还成功注册了我的上下文提供程序:

    curl -iX POST \
  'http://localhost:1026/v2/entities' \
  -H 'Content-Type: application/json' \
  -d '
{
    "id": "urn:ngsi-ld:Store:001",
    "type": "Store",
    "address": {
        "type": "PostalAddress",
        "value": {
            "streetAddress": "Bornholmer Straße 65",
            "addressRegion": "Berlin",
            "addressLocality": "Prenzlauer Berg",
            "postalCode": "10439"
        }
    },
    "location": {
        "type": "geo:json",
        "value": {
             "type": "Point",
             "coordinates": [13.3986, 52.5547]
        }
    },
    "name": {
        "type": "Text",
        "value": "Bösebrücke Einkauf"
    }
}'

上下文提供者

我在http://192.168.xxx.xxx:8080/temperature本地公开了Context Provider(由用Java 10编写的SpringBoot应用程序公开)。 JSON数据(以html正文返回)为NSGI v1格式,如下所示:

    curl -iX POST   'http://localhost:1026/v2/registrations'   -H 'Content-Type: application/json'   -d '{
  "description": "Temperature Provider",
  "dataProvided": {
    "entities": [
      {         
        "id": "urn:ngsi-ld:Store:001",
        "type": "Store"
      }                                             
    ],                                
    "attrs": [                                   
      "temperature"
    ]    
  },
  "provider": {
    "http": {
      "url": "http://192.168.xxx.xxx:8080/temperature"
    },                       
     "legacyForwarding": true
  }      
}'

问题

当我尝试获取其他实体的属性(例如名称)时,它工作正常,但是当我尝试通过此查询获取温度属性时:

{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "temperature",
            "type": "float",
            "value": "16"
          }
        ],
        "id": "urn:ngsi-ld:Store:001",
        "isPattern": "false",
        "type": "Store"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

我收到以下错误:

curl -X GET   'http://192.168.xxx.xxx:1026/v2/entities/urn:ngsi-ld:Store:001/attrs/temperature/value'

登录上下文代理docker:

{"error":"NotFound","description":"The entity does not have such an attribute"}

我是否需要在设置中添加更多内容以使此上下文提供程序起作用(例如特殊上下文代理)?

1 个答案:

答案 0 :(得分:1)

Okey,我花了一些时间,但是我找到了答案。在这种情况下,不需要代理。

上下文代理不是发出GET,而是发出POST请求,而不是给定url,而是url +“ / queryContext”。我更改了REST客户端,现在对我来说很好用。