首页 文章

Orion Context Broker Fiware中订阅的属性参考

提问于
浏览
1

我需要在引用属性中添加什么?

我正在使用两种形式,这两种形式对 Orion Context Broker 不利:

URL url = new URL("http://130.206.127.23:1026/ngsi10/notifyContext");
//String url = "http://localhost:1028/accumulate";
cabecera.put("reference", ""+url);

使用此代码,我将为 reference 属性生成下一个 JSON String

...."reference":"http:\/\/130.206.127.23:1026\/ngsi10\/notifyContext",...

这是 OCB 的回应

<subscribeContextResponse>
  <subscribeError>
    <errorCode>
      <code>400</code>
      <reasonPhrase>Bad Request</reasonPhrase>
      <details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
    </errorCode>
  </subscribeError>
</subscribeContextResponse>

还与此参数有关,我是否需要在服务器中执行程序才能接收有关我的订阅的信息?
我可以从Orion Context Broker资源中获取程序来执行此任务吗?

以下是我调用服务的JSON,但我不确定引用属性 . 我想发送订阅我的Orion Context Broker实例 . 我发送这个JSON:

{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}

提前致谢 .

1 回答

  • 1

    参考元素在the Orion User Manual中描述:

    使用引用元素定义发送通知的回调URL .

    因此,如果您的引用是 http://130.206.127.23:1026/ngsi10/notifyContext ,如示例所示,您应该在主机130.206.127.23端口1026处侦听REST服务器,能够在 /ngsi10/notifyContext 路径中接收通知 . 请注意,您的CB(我的意思是,您发送subscribeContext请求的那个)是发送通知的actor,而不是接收它们的actor,所以它在130.206.127.23:1026运行 .

    您可以使用任何所需的编程语言实现通知接收器程序(只要它实现了所需的REST服务器接口) . 您可以查看accumulator-server.py,这是一个用Python实现的"dummy"通知接收器示例,用于测试 .

相关问题