2014-01-08 18 views
89

我正在開發網絡視頻接口論壇Java項目,並按照ONVIF Application Programmer's Guide中描述的步驟進行操作。從Open ONVIF(網絡視頻接口論壇)設備錄製問題

我已經從ONVIF網站提供的wsdls生成了源代碼。我可以使用media.wsdl檢索實時流URI。現在我遇到了錄製問題。我已經嘗試過的代碼在下面給出:

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 
+5

請注意,「錄製」是ONVIF錄像機使用的服務:大多數網絡攝像機不支持它。我認爲你應該在設備功能中檢查它,因爲它是一個可選的服務(取決於所支持的配置文件):http://www.onvif.org/ver10/device/wsdl/GetCapabilities。還有一點需要注意:在最後一行中,您將getRecordings()分配給「功能」......查看http://www.onvif.org/onvif/ver10/recording.wsdl - 我會說這是輸出類型爲GetServiceCapabilities()。請仔細檢查一下。 – Sigismondo

+1

應該檢查Web服務器的安全策略,因爲方法似乎存在於代碼中,但客戶端不允許或不可訪問。 – Ved

+0

同意Ved ...無論誰在實現這個WSDL,都沒有實現某些特性,或者這個名稱空間指向一個不包含該函數的WSDL聲明。就我個人而言,我對WSDL的ONVIF選擇感到吃驚。 –

回答

2

當您嘗試使用媒體源時,您顯然請求了未經授權的操作,因爲服務器返回了錯誤代碼405.該方法被禁止使用,或者您需要憑證才能使用方法d。

對於Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Method 'ns11:GetServiceCapabilities' not implemented: method name or namespace not recognized,@Sigismondo是正確的事實,大多數網絡攝像機不支持它。你將需要一個替代記錄方法(文字和雙關語)從IP攝像機記錄。

1

您正在使用http://" + deviceip + "/onvif/media_service來達到錄製服務,但這是一個media.wsdl服務。所以當你嘗試在媒體服務上調用getRecordings時,你會收到一個錯誤。

recording.wsdl服務的網址應該是http://" + deviceip + "/onvif/recording_service

爲了獲得corect URL以訪問錄製服務,您應該從devicemgmt.wsdl服務的GetCapabilities方法請求它。

0

HTTP 405 - 資源不允許通常發生在IIS中。

  • 你不指定文件名:如果滿足下列條件,則會出現 此問題。例如,您沒有指定 http:// Server/Web/...

  • 已啓用腳本對象模型(SOM)。

  • DTC事件被調用。

所以,當SOM啓用了<形式>標籤在網頁中插入標籤無效意味着它不包含任何行動。