ONVIF - start device discovery

I plan to make a java onvif application. I created a new project and created sources from devicemgmt.wsdl.Also generated classes from remote discovery.wsdl. How can I detect a device on the network using the points of the generated classes? Thanks for any help.

+6
source share
2 answers

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

If you are using apache-cxf, this can be achieved with

org.apache.cxf.ws.discovery.WSDiscoveryClient

A simple code example 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()); } } } 
+4
source

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

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

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

+1
source

All Articles