ONVIF - beginning of Device discovery

后端 未结 2 602
有刺的猬
有刺的猬 2020-12-10 17:37

I am planning to do a java onvif application. I have created a new project and generated sources from devicemgmt.wsdl.Also generated the classes from remote discovery.wsdl.

相关标签:
2条回答
  • 2020-12-10 17:49

    devicemgmt.wsdl is not related to discovery process, the ONVIF discovery process is based on http://specs.xmlsoap.org/ws/2005/04/discovery it use SOAP over UDP.

    If you are using apache-cxf, this can be achieve using

    org.apache.cxf.ws.discovery.WSDiscoveryClient

    A simple sample code could be :

    import java.util.List;
    import javax.xml.ws.EndpointReference;
    import org.apache.cxf.ws.discovery.WSDiscoveryClient;
    
    public class Main 
    {
        public static void main(String[] args) 
        {
            WSDiscoveryClient client = new WSDiscoveryClient();
            client.setVersion10(); // use WS-discovery 1.0
            client.setDefaultProbeTimeout(1000); // timeout 1s
    
            System.out.println("Probe:" + client.getAddress());
            List<EndpointReference> references = client.probe();
    
            System.out.println("Nb answsers:" + references.size());
            for (EndpointReference ref : references)
            {
                System.out.println(ref.toString());
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-10 18:01

    I had the same problem, CXF is simply to big, please check my approach: JavaWsDiscovery at https://github.com/thhart/javaWsDiscovery.

    It uses a simple network probe as suggested by Onvif standards to be able to identify any devices on your local network, following line will return you all available devices:

    final Collection urls = DeviceDiscovery.discoverWsDevicesAsUrls("^http$", ".onvif.");

    0 讨论(0)
提交回复
热议问题