首页 文章

Proton Orion Subscription - 解析通知XML时出错

提问于
浏览
0

我已经配置了Orion和Proton FIWARE Generic Enablers并在Orion中进行了订阅,以便在修改Node类型的实体时向Proton发送通知 .

碰巧Proton返回与解析收到的XML有关的错误 .

proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | INFO: started event message body reader
proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | INFO: Event: NodeContextUpdate
proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | SEVERE: Could not parse XML NGSI event java.lang.NullPointerException, reason: null
proton |  last attribute name: null last value: null

我发现至少另一个用户发布了类似的问题,但该问题的答案并不适合(并解决)我的情况 .

编辑:

这是Proton收到的POST请求:

........POST /ProtonOnWebServer/rest/events HTTP/1.1
User-Agent: orion/0.27.0-next libcurl/7.19.7
Host: 192.168.99.100:8080
Accept: application/xml, application/json
Content-length: 901
Content-type: application/xml

<notifyContextRequest>
  <subscriptionId>570b7cad849a7fd6c9ebaaf3</subscriptionId>
  <originator>localhost</originator>
  <contextResponseList>
    <contextElementResponse>
      <contextElement>
        <entityId type="Node" isPattern="false">
          <id>Node3</id>
        </entityId>
        <contextAttributeList>
          <contextAttribute>
            <name>temperature</name>
            <type>double</type>
            <contextValue>23</contextValue>
          </contextAttribute>
          <contextAttribute>
            <name>pressure</name>
            <type>double</type>
            <contextValue>15</contextValue>
          </contextAttribute>
        </contextAttributeList>
      </contextElement>
      <statusCode>
        <code>200</code>
        <reasonPhrase>OK</reasonPhrase>
      </statusCode>
    </contextElementResponse>
  </contextResponseList>
</notifyContextRequest>

谢谢 .

1 回答

  • 0

    只是为了看到这个帖子的其他人,这是何塞对他解决这个问题的解释 . 我希望何塞对此表示满意:

    我第一次遇到类似的错误,我没有在Orion中订阅以XML格式发送信息 . 解决方案是使用“Accept”:“application / xml”它是订阅POST resquest的标头,以便Orion在XML NGSI中通知Proton . (应该使用XML的原因是因为Proton接受的JSON格式不是NGSI) . 这次我忘记将entityType属性放在NodeContextUpdate事件定义中 .

相关问题