Proton Orion 订阅 - 解析通知时出错 XML
Proton Orion Subscription - Error when parsing notification XML
我已经配置了 Orion 和 Proton FIWARE 通用启动器,并在 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>
谢谢。
为了其他查看此线程的人,这里是何塞对他解决此问题的解释。我希望 Jose 对此表示满意:
The first time I've run into an similar error, I was not making the
subscription in Orion to send the information in XML format. The
solution was to use "Accept":"application/xml" it the header of the
subscription POST resquest in order to Orion to notify Proton in XML
NGSI. (The reason XML should be used is because the JSON format
accepted by Proton is not NGSI).
This time I was just forgetting to put entityType attribute in the
NodeContextUpdate event definition.
我已经配置了 Orion 和 Proton FIWARE 通用启动器,并在 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>
谢谢。
为了其他查看此线程的人,这里是何塞对他解决此问题的解释。我希望 Jose 对此表示满意:
The first time I've run into an similar error, I was not making the subscription in Orion to send the information in XML format. The solution was to use "Accept":"application/xml" it the header of the subscription POST resquest in order to Orion to notify Proton in XML NGSI. (The reason XML should be used is because the JSON format accepted by Proton is not NGSI).
This time I was just forgetting to put entityType attribute in the NodeContextUpdate event definition.