ONVIF - 设备发现的开始

Nee*_*enu 6 java ip camera ip-camera onvif

我打算做一个java onvif应用程序.我创建了一个新项目并从devicemgmt.wsdl生成了源.还从远程discovery.wsdl生成了类.如何使用生成的类发现网络中的设备?谢谢你的帮助.

mpr*_*net 4

devicemgmt.wsdl 与发现过程无关,ONVIF 发现过程基于http://specs.xmlsoap.org/ws/2005/04/discovery,它使用 UDP 上的 SOAP。

如果您使用 apache-cxf,这可以通过使用来实现

org.apache.cxf.ws.discovery.WSDiscoveryClient

一个简单的示例代码可以是:

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());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)