2014-12-03 45 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的服務來修復它。