为了使用 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 创建的,并且我自己设置了绑定(bind)。 我无法以相同的方式创建拉取消息 WS,因为我没有封装到 pullPointSubscription 对象中的引用点(并且它们是私有(private)的)。
我正在寻找一种方法让 PullPointSubscription 了解当前的 SOAP 版本,以便我能够接收事件响应。
最佳答案
我已经通过一些变通办法解决了这个问题。 我使用 .toString() 从响应中提取了私有(private)参数,解析了字符串,提取了参数,并创建了一个具有正确版本和参数的新 PullPointSubscription 对象。
关于java - 如何使用 Java ONVIF Web 服务从摄像头提取 ONVIF 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43658431/