如何解决Fiware Context Provider hello world 不工作
我正在尝试将上下文提供程序注册为多个 KPI 的来源。
到目前为止,注册似乎可以正常工作,因为 GET http://{{orion}}/v2/registrations 返回类似于我在创建中设置的内容:
{
// 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."
}
GET http://{{orion}}/v2/entities?type=KeyPerformanceIndicator 返回 [] 并且不会以任何方式调用 context-provider。
我正在从头开始编写 Node.js 应用程序,以更好地了解发生了什么https://github.com/FIWARE/tutorials.Context-Providers,并使用教程容器作为实际的 Fiware broker,因此所有商店/货架/产品正在工作,但不是我的 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'
返回:
{
"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"
]
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。