2014-12-03 44 views
1

我打算使用Apache CXF进行ONVIF兼容的IP摄像机服务。它使用WS-Discovery可以找到设备和服务cxf supports it外的盒子:使用Apache CXF进行WS-Discovery。如何指定设备类型?

了CXF服务-WS发现服务的罐子会注册一个 ServerLifecyleListener将自动发布的“你好” 消息。它还将响应与其发布的 服务匹配的任何探查请求。

cxf如何检测设备类型在ProbeMatches响应中发送?我如何指定我的设备是IP摄像头(我需要在ProbeMatches响应中设置具体设备类型,例如NetworkVideoTransmitter)?

回答

0

寻找到CXF的源代码(WSDiscoveryServiceImpl类)后,我已经找到了答案:

public ProbeMatchesType handleProbe(ProbeType pt) { 
     List<HelloType> consider = new LinkedList<HelloType>(registered); 
     //step one, consider the "types" 
     //ALL types in the probe must be in the registered type 
     if (pt.getTypes() != null && !pt.getTypes().isEmpty()) { 
      ListIterator<HelloType> cit = consider.listIterator(); 
      while (cit.hasNext()) { 
       HelloType ht = cit.next(); 
       boolean matches = true; 
       for (QName qn : pt.getTypes()) { 
        if (!ht.getTypes().contains(qn)) { 
         matches = false; 
        } 
       } 
       if (!matches) { 
        cit.remove(); 
       } 
      } 
     } 
     //next, consider the scopes 
     matchScopes(pt, consider); 

     if (consider.isEmpty()) { 
      return null; 
     } 
     ProbeMatchesType pmt = new ProbeMatchesType(); 
     for (HelloType ht : consider) { 
      ProbeMatchType m = new ProbeMatchType(); 
      m.setEndpointReference(ht.getEndpointReference()); 
      m.setScopes(ht.getScopes()); 
      m.setMetadataVersion(ht.getMetadataVersion()); 
      m.getTypes().addAll(ht.getTypes()); 
      m.getXAddrs().addAll(ht.getXAddrs()); 
      pmt.getProbeMatch().add(m); 
     } 
     return pmt; 
    } 

简单 - 它遍历发布的服务和比较的QName。如果搜索到的qname已在发布中找到,则将其添加到ProbeMatch中。所以我应该实施和发布具有所需QName的服务来修复它。