首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ONVIF PullPointSubscriptionClient.PullMessages

ONVIF PullPointSubscriptionClient.PullMessages
EN

Stack Overflow用户
提问于 2015-03-04 11:42:24
回答 1查看 2.5K关注 0票数 4

我正在尝试从一些ONVIF设备中获取事件消息。我的代码在C#中。

EventPortTypeClient.CreatePullPointSubscription上的(轴相机)设备上返回:

代码语言:javascript
复制
Address.Value: http : / /192.168.8.48/onvif/services
ReferenceParameters.Any.First().OuterXml: <dom0:SubscriptionId xmlns:dom0="http : / /www.axis.com/2009/event">38</dom0:SubscriptionId>

因此,我将“添加到”和 soap头中,并可以使用PullPointSubscriptionClient.PullMessages("PT5M", 99, Any, out CurrentTime, out NotificationMessages)获取事件消息。

代码语言:javascript
复制
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesRequest</a:Action>
    <a:MessageID>urn:uuid:f243dbe4-b082-4a6c-aa65-8145468fcf3e</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo0zfnhoyh15KqPZwP/IS9H0AAAAAdCoo8EjbCUScx/bG/DGcdXp8kY6WrAJDp0TTtNAtj0EACQAA</VsDebuggerCausalityData>
    <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-GWt5XP2ogUljZ/fzEJvnX0WhGpx3FV4i/dRnE539OFU=">
        <wsse:Username xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">root</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">pjwOOO0hOXtUZyJb6B6Lb0ctRIU=</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">DEE/P1c/P1E/eG9XTT87Pz8/</wsse:Nonce>
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2015-03-02T19:06:54.269Z</wsu:Created>
      </wsse:UsernameToken>
    </Security>
    <a:To s:mustUnderstand="1">http://192.168.8.48/onvif/services</a:To>
    <SubscriptionId s:mustUnderstand="1" xmlns="http://www.axis.com/2009/event">38</SubscriptionId>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <PullMessages xmlns="http://www.onvif.org/ver10/events/wsdl">
      <Timeout>PT5M</Timeout>
      <MessageLimit>99</MessageLimit>
    </PullMessages>
  </s:Body>
</s:Envelope>

但是对于只返回地址的设备,return如下所示:

  • (大华) Address.Value:http : / /192.168.8.243/onvif/Subscription?Idx=57
  • (Siqura) Address.Value: http : / /192.168.8.14/onvif/events_service/SubscriptionManager/15000

我只将“添加到” soap头中,但是PullPointSubscriptionClient.PullMessages("PT5M", 99, Any, out CurrentTime, out NotificationMessages)方法提供了一个错误错误。

代码语言:javascript
复制
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesRequest</a:Action>
    <a:MessageID>urn:uuid:9e28fea7-541f-450e-8ad0-01a210f76aa9</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPozBB+X6a8MJEsKScTDAWhKsAAAAAJ3lo8k+wp0CaILCjmW72gQ39eqv52SBMteWBucAF600ACQAA</VsDebuggerCausalityData>
    <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-IYP/hqttMbWUf7ljIMnByJQv96x2VxajSEnVHBKfLyo=">
        <wsse:Username xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">admin</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">o3Nrz8F+V7kLjMunS/JBQKhu5xg=</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">PxtFP2k/Pz8/P2g/Pz8/Bz8=</wsse:Nonce>
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2015-03-02T19:03:36.894Z</wsu:Created>
      </wsse:UsernameToken>
    </Security>
    <a:To s:mustUnderstand="1">http://192.168.8.243/onvif/Subscription?Idx=57</a:To>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <PullMessages xmlns="http://www.onvif.org/ver10/events/wsdl">
      <Timeout>PT5M</Timeout>
      <MessageLimit>99</MessageLimit>
    </PullMessages>
  </s:Body>
</s:Envelope>

在这方面有什么帮助吗?

解决方案:

代码语言:javascript
复制
System.Xml.XmlElement[] Any = new System.Xml.XmlElement[] { };
System.DateTime CurrentTime;
System.Nullable<System.DateTime> TerminationTime;
List<MessageHeader> lstHeaders = new List<MessageHeader>() { };
var oEventClient = _session.GetEventPortTypeClient();

var oAux1 = oEventClient.CreatePullPointSubscription(
    new onvif10_events.FilterType(),
    "PT600S",
    new onvif10_events.CreatePullPointSubscriptionSubscriptionPolicy(),
    ref Any,
    out CurrentTime,
    out TerminationTime);

if ((oAux1.ReferenceParameters != null) && (oAux1.ReferenceParameters.Any != null))
{
    foreach (System.Xml.XmlElement oXml in oAux1.ReferenceParameters.Any)
    {
        string strName = oXml.LocalName;
        string strNS = oXml.NamespaceURI;
        string strValue = oXml.InnerXml;

        lstHeaders.Add(MessageHeader.CreateHeader(strName, strNS, strValue, true));
    }
}

// oAux1.Address.Value -> the proxy endpoint address
// lstHeaders -> headers to add to the SOAP message of the proxy request
var oPullPointSubscriptionClient = _session.GetPullPointSubscriptionClient(oAux1.Address.Value, lstHeaders);
var oSubscriptionManagerClient = _session.GetSubscriptionManagerClient(oAux1.Address.Value, lstHeaders);

do
{
    oPullPointSubscriptionClient.PullMessages("PT60S", 1024, Any, out CurrentTime, out NotificationMessages);

    foreach (onvif10_events.NotificationMessageHolderType message in NotificationMessages)
    {
        /// Handle message
    }

    var oRenewResult = oSubscriptionManagerClient.Renew(new LIB.Cameras.ONVIF_WS.onvif10_events.Renew() { TerminationTime = "PT600S" });    

} while (_session != null);

oSubscriptionManagerClient.Unsubscribe(new onvif10_events.Unsubscribe());
EN

回答 1

Stack Overflow用户

发布于 2015-03-09 14:48:30

好的。" to“标题是忽略的。PullPointSubscriptionClient代理端点URL是订阅"Address.Value“(而不是"TO”url)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28853553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档