Fiware 上下文提供程序你好世界不工作

Fiware Context Provider hello world not working

我正在尝试将上下文提供程序注册为多个 KPI 的来源。

到目前为止,似乎注册可能有效,因为 GET http://{{orion}}/v2/registrations returns 类似于什么我在创作中设置:

{
    // each registering a new id is returned: "id": "60991a887032541f4539a71d",
    "description": "City Inhabitants",
    "dataProvided": {
        "entities": [
            {
                "id": "city.inhabitants"
                //,"type": "KeyPerformanceIndicator"
            }
        ]
    },
    "provider": {
        "http": {
            "url": "http://myhost/v2/inhabitants"
        }
        //, "legacyForwarding": false //perhaps there's a bug, cause although unset or set to false, broker still returns true.
    }
}

但是 GET http://{{orion}}/v2/entities/city.inhabitants 结果:

{
    "error": "BadRequest",
    "description": "Service not found. Check your URL as probably it is wrong."
}

获取 http://{{orion}}/v2/entities?type=KeyPerformanceIndicator returns [] 并且没有以任何方式调用上下文提供程序。

我正在从头开始编写一个 Node.js 应用程序,以便更好地了解正在发生的事情 https://github.com/FIWARE/tutorials.Context-Providers,并将教程容器用作实际的 Fiware Broker,所以所有 stores/shelf/products 正在工作,但不是我的 KPI。

使用微服务侦听 http://context-provider:3000/random/weatherConditions POST 端点的教程应用程序。

以下报名:

curl -L -X POST 'http://localhost:1026/v2/registrations' \
-H 'Content-Type: application/json' \
--data-raw '{
   "description": "Get Weather data for KPI 1",
   "dataProvided": {
     "entities": [
       {
         "id" : "urn:ngsi-ld:KPI:010",
         "type": "KeyPerformanceIndicator"
       }
     ],
     "attrs": [
      "temperature", "relativeHumidity"
    ]
   },
   "provider": {
     "http": {
       "url": "http://context-provider:3000/random/weatherConditions"
     },
     "legacyForwarding": false
   },
   "status": "active"
}'

将为以下请求转发和检索数据:

curl -L -X GET 'http://localhost:1026/v2/entities/urn:ngsi-ld:KPI:010'

curl -L -X GET 'http://localhost:1026/v2/entities/?type=KeyPerformanceIndicator'

Returns:

{
    "id": "urn:ngsi-ld:KPI:010",
    "type": "KeyPerformanceIndicator",
    "temperature": {
        "type": "Number",
        "value": 11,
        "metadata": {}
    },
    "relativeHumidity": {
        "type": "Number",
        "value": 39,
        "metadata": {}
    }
}

上下文代理正在将请求转发到 http://context-provider:3000/random/weatherConditions POST 具有以下有效负载的端点:

{
 "entities": [
  {
   "id": "urn:ngsi-ld:KPI:010",
   "type": "KeyPerformanceIndicator"
  }
 ],
 "attrs": [
  "temperature",
  "relativeHumidity"
 ]
}