简单对象访问协议(soap)连接为空

9w11ddsr  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(341)

我正在尝试使用onvif库和从这里复制的java代码中的示例代码连接到相机
当我尝试连接到相机时,它会在初始化时出错 OnvifDevice nvt = new OnvifDevice("172.16.20.37", "admin", "password"); 错误是

Unexpected response. Response should be from class class org.onvif.ver10.device.wsdl.GetCapabilitiesResponse, but response is: null
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "javax.xml.soap.SOAPConnection.close()" because "soapConnection" is null
    at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:137)
    at de.onvif.soap.devices.InitialDevices.getCapabilities(InitialDevices.java:141)
    at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:149)
    at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:89)
    at de.onvif.Main.main(Main.java:117)

我的代码如下

package de.onvif;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.util.List;

import javax.xml.soap.SOAPException;

import org.onvif.ver10.schema.Profile;

import de.onvif.soap.OnvifDevice;

import java.net.ConnectException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.soap.SOAPException;

import de.onvif.soap.OnvifDevice;

public class Main 
{
    public static void main(String[] args) 
    {
        try 
        {
            OnvifDevice nvt = new OnvifDevice("172.16.20.37", "admin", "password");
            Date nvtDate = nvt.getDevices().getDate();
            System.out.println(new SimpleDateFormat().format(nvtDate));
        }
        catch (ConnectException e)
        {
            System.err.println("Could not connect to NVT.");
        }
        catch (SOAPException e) {
            e.printStackTrace();
        }
    }
}

有谁能告诉我有什么问题吗?它与onvif或java代码或任何其他依赖关系有关?任何帮助都将不胜感激。使用onvif设备管理器(使用相同的用户和密码),设备可以完美地工作。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题