Orion Context Broker Fiware中的订阅服务



我正在阅读有关OCB订阅的文档,但一无所获。只有一个Python示例,名为accumulator.py(我不知道Python:(,我是Java开发人员)。我指的是Orion由于订阅而发送的通知,即您可以在属性reference 中指示的服务

它是GET服务还是POST?它需要任何参数吗?我正在编写一个带有param的RESTGET服务,这是OrionContextBroker必须发送给我的JSON字符串,以更新我的应用程序。这是正确的吗??

你能帮我吗?

提前感谢

我建议您查看Orion Context Broker用户手册,其中提供了有关HTTP谓词、操作URL和参数的所有信息。

更新:关于Orion发送的通知,手册中包括一些示例,如以下示例:

POST http://localhost:1028/accumulate
Content-Length: 492
User-Agent: orion/0.9.0
Host: localhost:1028
Accept: application/xml, application/json
Content-Type: application/json
{
  "subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
  "originator" : "localhost",
  "contextResponses" : [
    {
      "contextElement" : {
        "attributes" : [
          {
            "name" : "temperature",
            "type" : "float",
            "value" : "26.5"
          }
        ],
        "type" : "Room",
        "isPattern" : "false",
        "id" : "Room1"
      },
      "statusCode" : {
        "code" : "200",
        "reasonPhrase" : "OK"
      }
    }
  ]
}

正如您在上面的片段中看到的,使用的动词是POST(而不是GET)。因此,您应该准备代码侦听通知,以便在正确的URL中接收POST请求(在本例中,URL为/accumulate),并根据应用程序的需要处理有效负载。

例如,在Python中,您可以使用装饰器(使用Flask框架):

@app.route('/accumulate', methods=['POST'])
def process_notification():
    # Do whatever you want with the request payload

我不知道REST服务器编程在Java中是如何工作的,但我想类似的方法也是可能的。

最新更新