問題描述
我打算做一個 java onvif 應用程序.我創建了一個新項目并從 devicemgmt.wsdl 生成了源代碼.還從 remote discovery.wsdl 生成了類.如何使用這些生成的類發現網絡中的設備?感謝您的幫助.
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. How can I discover a device in a network using theses generated classes? Thanks for any help.
推薦答案
devicemgmt.wsdl與發現過程無關,ONVIF發現過程基于http://specs.xmlsoap.org/ws/2005/04/discovery 它使用 SOAP over UDP.
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.
如果你使用的是apache-cxf,這可以使用
If you are using apache-cxf, this can be achieve using
org.apache.cxf.ws.discovery.WSDiscoveryClient
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());
}
}
}
這篇關于ONVIF - 設備發現的開始的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!