90

我正在开发 Open Network Video Interface Forum-Java 项目,并按照ONVIF Application Programmer's Guide中描述的步骤进行操作。

我已经从wsdlsONVIF 站点中提供的源代码中生成了源代码。我可以使用media.wsdl. 现在我有一个记录问题。我尝试过的代码如下:

RecordingService recording_ervice = new RecordingService();
RecordingPort record_port = recording_ervice.getRecordingPort();


BindingProvider bindingProvider = (BindingProvider) record_port;

// Add a security handler for the credentials
final Binding binding = bindingProvider.getBinding();
List<Handler> handlerList = binding.getHandlerChain();
if (handlerList == null) {
    handlerList = new ArrayList<Handler>();
}

handlerList.add(new RecordStream.SecurityHandler());
// binding.setHandlerChain(handlerList);

// Set the actual web services address instead of the mock service
Map<String, Object> requestContext = bindingProvider.getRequestContext();

requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://" + deviceip + "/onvif/media_service");
requestContext.put(BindingProvider.USERNAME_PROPERTY, user);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, pass);

Recordings recordings = record_port.getRecordings();

上面的代码在运行时给出了一个错误:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Method 'ns11:GetServiceCapabilities' not implemented: method name or namespace not recognized

我也尝试了媒体服务,然后错误是:

Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 405: Method Not Allowed
4

3 回答 3

2

当您尝试使用媒体源时,您显然请求了未经授权的操作,因为服务器返回了错误代码 405。该方法被禁止使用,或者您需要凭据才能使用该方法。

至于Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Method 'ns11:GetServiceCapabilities' not implemented: method name or namespace not recognized,@Sigismondo 是正确的,因为大多数网络摄像机不支持它。您将需要另一种录制方法(文字和双关语)从网络摄像机录制。

于 2014-08-12T02:11:29.137 回答
1

http://" + deviceip + "/onvif/media_service用于访问 Recording 服务,但这是一个media.wsdl服务。因此,当您尝试在媒体服务上调用 getRecordings 时,您收到错误似乎很正常。

Recording.wsdl服务的 url应该是http://" + deviceip + "/onvif/recording_service.

为了获得正确的 URL 以访问录制服务,您应该从devicemgmt.wsdl服务的 GetCapabilities 方法请求它。

于 2014-08-17T21:54:23.863 回答
0

HTTP 405 - 不允许的资源通常发生在 IIS 中。如果满足以下条件,则会出现此问题:

  • 您没有指定文件名。例如,您不指定 http://Server/Web/...

  • 脚本对象模型 (SOM) 已启用。

  • 调用 DTC 事件。

因此,当启用 SOM 时,在页面中插入了一个<form>标签,该标签无效意味着它不包含任何操作。

于 2014-08-20T08:37:54.000 回答