如何使用 Java ONVIF 网络服务从相机中提取 ONVIF 事件

How to pull an ONVIF event from a camera using Java ONVIF web services

为了使用 ONVIF 从安讯士相机中提取事件,我创建了以下内容:

CreatePullPointSubscriptionResponse pullPointSubscriptionResponse = event.createPullPointSubscription(parameters);
PullPointSubscription pullPointSubscription = pullPointSubscriptionResponse.getSubscriptionReference().getPort(PullPointSubscription.class);
PullMessages pullMessagesParameters = new PullMessages();
pullMessagesParameters.setMessageLimit(1);
javax.xml.datatype.Duration duration = DatatypeFactory.createDuration("PT1M");
pullMessagesParameters.setTimeout(duration);
try {

    PullMessagesResponse pullMessageResponse =
        pullPointSubscription.pullMessages(pullMessagesParameters);
} catch (PullMessagesFaultResponse_Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
int d = 1;
catch(TopicNotSupportedFault | TopicExpressionDialectUnknownFault | InvalidTopicExpressionFault
    | InvalidMessageContentExpressionFault | InvalidProducerPropertiesExpressionFault
    | UnacceptableInitialTerminationTimeFault | NotifyMessageNotSupportedFault | ResourceUnknownFault
    | UnsupportedPolicyRequestFault | InvalidFilterFault | SubscribeCreationFailedFault
    | UnrecognizedPolicyRequestFault e)

{
    // TODO Auto-generated catch block
    e.printStackTrace();
}

我的问题是,当执行 pullMessages 时,Web 服务是使用 SOAP1.1 创建的,而相机需要 SOAP1.2(我收到版本不匹配错误响应)。

createPullPointSubscription 创建了一个很好的版本 Web 服务,因为我创建的是 JaxWsProxyFactoryBean 并且我自己设置了绑定。 我无法以相同的方式创建拉取消息 WS,因为我没有封装到 pullPointSubscription 对象中的参考点(并且它们是私有的)。

我正在寻找一种方法让 PullPointSubscription 知道当前的 SOAP 版本,这样我就能收到事件响应。

我已经通过一些变通方法解决了这个问题。 我使用 .toString() 从响应中提取了私有参数,解析了字符串,提取了参数,并创建了一个具有正确版本和参数的新 PullPointSubscription 对象。