Onvif - разбор уведомлений о событиях из WS-BaseNotification - PullRequest
1 голос
/ 29 апреля 2020

В настоящее время я реализую обработчик событий для Onvif. Но я полностью потерян с процессом демаршаллинга WS-BaseNotification.

  1. Как я могу понять / проанализировать NotificationMessageHolderType для реализации события onvif?

  2. Полагаю, в ws-basenotification есть метод для сопоставления сообщения "generi c" с пользовательской реализацией. Где ссылка / информация к схеме для использования?

Мой тестовый код : абонент конечной точки

private W3CEndpointReference subscribe(final FilterType filterType) {
    try {
        CreatePullPointSubscription parameters = new CreatePullPointSubscription();
        parameters.setFilter(filterType);
        CreatePullPointSubscriptionResponse pullPointSubscription = onvifDevice.getEventPort().createPullPointSubscription(parameters);
        return pullPointSubscription.getSubscriptionReference();

    } catch (TopicNotSupportedFault | InvalidMessageContentExpressionFault | InvalidProducerPropertiesExpressionFault | InvalidTopicExpressionFault | TopicExpressionDialectUnknownFault | UnacceptableInitialTerminationTimeFault | NotifyMessageNotSupportedFault | ResourceUnknownFault | UnsupportedPolicyRequestFault | InvalidFilterFault | SubscribeCreationFailedFault | UnrecognizedPolicyRequestFault topicNotSupportedFault) {
        topicNotSupportedFault.printStackTrace();
        return null;
    }
}

И я могу получать уведомления и отменять их отправку в org.onvif.ver10. schema.Message.class:

Получение уведомления

PullMessagesResponse pullMessagesResponse = pullPointSubscription.pullMessages(pullMessages);
List<NotificationMessageHolderType> notificationMessage = pullMessagesResponse.getNotificationMessage();

// Some test to have understandable data.
TopicExpressionType topic = notificationMessage.get(0).getTopic();
JAXBContext context = JAXBContext.newInstance(org.onvif.ver10.schema.Message.class, AccessPointState.class);
Unmarshaller um = context.createUnmarshaller();
Object response = (Object)um.unmarshal((Node)node);

Пример

PullMessagesResponse, отправленный устройством (захват Wireshark ):

<tev:PullMessagesResponse>
    <tev:CurrentTime>2020-04-29T11:41:52Z</tev:CurrentTime>
    <tev:TerminationTime>2020-04-29T11:46:51Z</tev:TerminationTime>
    <wsnt:NotificationMessage>
        <wsnt:Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple">tns1:AccessPoint/State/Enabled</wsnt:Topic>
        <wsnt:ProducerReference>
            <wsa5:Address>uri://5581ad80-95b0-11e0-b883-accc8e251272/ProducerReference</wsa5:Address>
        </wsnt:ProducerReference>
        <wsnt:Message>
            <tt:Message UtcTime="2020-04-23T15:21:26.924984Z" PropertyOperation="Initialized">
                <tt:Source>
                    <tt:SimpleItem Name="AccessPointToken" Value="Axis-accc8e251272:1584710973.159018000"></tt:SimpleItem>
                    <tt:SimpleItem Name="Device Source" Value="5581ad80-95b0-11e0-b883-accc8e251272"></tt:SimpleItem>
                </tt:Source>
                <tt:Key></tt:Key>
                <tt:Data>
                    <tt:SimpleItem Name="State" Value="1"></tt:SimpleItem>
                </tt:Data>
            </tt:Message>
        </wsnt:Message>
    </wsnt:NotificationMessage>
</tev:PullMessagesResponse>

Тогда нематериальный результат для onvif.ssage:

enter image description here

Приложение

В руководстве по спецификации ядра Onvif написано (p106):

A notification answers the following questions: 
• When did it happen?
• Who produced the event? 
• What happened? 

 ... text ommited 

The “what” question is answered in two steps. First, the Topic element of the NotificationMessage is used to categorize the Event. Second, items are added to the Data element of the Message container in order to describe the details of the Event.

Так что я предполагаю темы из моего предыдущего примера "tns1: AccessPoint / State / Enabled" должен быть сопоставлен с типом? Но я не могу найти описание этой структуры, и во-вторых, я надеялся, что это сопоставление будет выполнено автоматически при генерации из файлов wsdl.

Профиль C - документация onvif описывает все существующие темы для моего устройства, но нет описания содержания этих уведомлений ...

Обновлено Видимо запрос: GetEventPropertiesResponse возвращает атрибуты, присутствующие в каждой теме. Поэтому я ищу способ сгенерировать «объект» из этого описания.

enter image description here

Спасибо за помощь

...