OnvifEventClient::PullMessages returns empty Message
Javierd opened this issue · comments
Hello,
I'm trying to use this library to pull message from an Optex InSight camera which supports ONVIF's pull points subscriptions.
Using the library I'm able to create a subscription and to pull messages from the device. However, these messages doesn't contain the message information, they only contain the Topic information, i.e., the wsnt__NotificationMessageHolderType::Message::Message object is always null.
I have been using other tools like ONVIF Device Manager and they show the message content (such as the UTC Time or the source). In fact, using Wireshark I can see that the responses to the requests sent by the library include the message field, as this example does:
<?xml
version="1.0"
encoding="UTF-8"
?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa5="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:xmime="http://tempuri.org/xmime.xsd"
xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2"
xmlns:ns1="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding"
xmlns:ns2="http://www.onvif.org/ver10/events/wsdl/EventBinding"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:ns3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding"
xmlns:ns4="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding"
xmlns:ns5="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding"
xmlns:ns6="http://www.onvif.org/ver10/events/wsdl/PullPointBinding"
xmlns:ns7="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding"
xmlns:ns8="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:ter="http://www.onvif.org/ver10/error">
<SOAP-ENV:Header>
<wsa5:MessageID>
urn:uuid:99d6f38c-0002-4336-aac9-bf229bf11696
</wsa5:MessageID>
<wsa5:To
SOAP-ENV:mustUnderstand="true">
http://support.vaelsys.com:4000/onvif/event_service?idx=5
</wsa5:To>
<wsa5:Action
SOAP-ENV:mustUnderstand="true">
http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse
</wsa5:Action>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tev:PullMessagesResponse>
<tev:CurrentTime>
2005-01-05T23:02:33Z
</tev:CurrentTime>
<tev:TerminationTime>
2038-01-01T00:00:00Z
</tev:TerminationTime>
<wsnt:NotificationMessage>
<wsnt:SubscriptionReference>
<wsa5:Address>
http://192.168.1.62/onvif/event_service?idx=5
</wsa5:Address>
</wsnt:SubscriptionReference>
<wsnt:Topic
Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">
tns1:VideoSource/MotionAlarm
</wsnt:Topic>
<wsnt:Message>
<tt:Message
UtcTime="2005-01-05T23:02:30Z"
PropertyOperation="Initialized">
<tt:Source>
<tt:SimpleItem
Name="Source"
Value="video_source_01"/>
</tt:Source>
<tt:Data>
<tt:SimpleItem
Name="State"
Value="false"/>
</tt:Data>
</tt:Message>
</wsnt:Message>
</wsnt:NotificationMessage>
</tev:PullMessagesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In this example, if the event is wsnt__NotificationMessageHolderType event*
, logging event->Topic->Dialect
I get http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet
, which is right, but event->Message.Message
is null.
Is this a bug in the library? Maybe the wsdl used by the library is outdated? Or what could the problem be?
Thanks a lot for your help.
Hi,
the NotificationMessageHolderType
unfortunately contains only a list of Message elements of any
type. Here is the xsd type definition of NotificationMessageHolderType
from the Web Services Base Notification 1.3 spec:
<xsd:complexType name="NotificationMessageHolderType">
<xsd:sequence>
<xsd:element ref="wsnt:SubscriptionReference" minOccurs="0" maxOccurs="1" />
<xsd:element ref="wsnt:Topic" minOccurs="0" maxOccurs="1" />
<xsd:element ref="wsnt:ProducerReference" minOccurs="0" maxOccurs="1" />
<xsd:element name="Message">
<xsd:complexType>
<xsd:sequence>
<!-- Message is of type 'any' -->
<xsd:any namespace="##any" processContents="lax" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
This means gsoap does not know how to deserialize this type (because it can be anything). That's why gsoap generates a member variable with the name __any
of type soap_dom_element*
in _wsnt__NotificationMessageHolderType_Message
. The Message
member variable of type _tt__Message*
was added by me to _wsnt__NotificationMessageHolderType_Message
(see here typemap.dat). The Message
member variable won't get initialized by gsoap (gsoap ignores it because it's a manually added member variable). You have to initialize the variable yourself by using the gsoap dom API and inspecting the __any
member variable.
I pushed a new commit to the dev branch where I populate the Message
member variable by using the dom API (see here) inspecting and casting the __any
member variable. I have also fixed another bug in OnvifPullPoint
class. Maybe the OnvifPullPoint
class works for you now. For testing: If you run onvifinfo --host ...
a new PullPoint is created and all messages are printed out.
Hi,
Thanks a lot for your rapid response. This was exactly what I was looking for. The OnvifPulPoint class seems to be working now.
Thanks again!