定义DeviceClient(Bind,endPointAddress) [英] Defining DeviceClient(Bind, endPointAddress)
问题描述
我正在尝试与 ONVIF 认证的设备进行交互,例如能够访问简单的设备信息.
I am trying to interface with ONVIF certified equipment, like being able to access simple device information.
我一直在尝试使用由另一位成员在此处提供的以下代码:
I have been trying to use the following code, provided by another member here:
使用Visual Studios的.NET 4.0中的ONVIF身份验证2010
但是,在了解 DeviceClient 是什么以及它的功能时遇到了麻烦. 我试图在 ONVIF WSDLs 上作为一个类来找到它,但是没有用. C#, WSDL 和 ONVIF 非常新,因此感谢您的帮助.
However, am having trouble understanding what the function DeviceClient is and what it does. I have tried to find it on the ONVIF WSDLs and as a class, but with no avail. Am very new to C#, WSDLs and ONVIF, and as such appreciate any help.
提前谢谢!
推荐答案
当我的代码无法识别DeviceClient
和MediaClient
类时,我也遇到了类似的问题.从Hugo的评论中,我得到了线索,并从我已经作为Web参考添加的C#项目中删除了OnVif参考.然后只需添加以下参考作为服务参考即可,它对我有用:
I was stuck with similar issue when my code was unable to recognize DeviceClient
and MediaClient
classes. From Hugo's comments I got the clue and removed OnVif references from my C# project which I'd already added as Web References. Then simply added following references as Service References and it worked for me:
- http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl
- http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl
- http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl
- http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl
下面是我从StackOverflow上的另一篇文章中摘录的工作代码段.
Below is the working code snippet I took from another post on StackOverflow.
ServicePointManager.Expect100Continue = false;
var endPointAddress = new EndpointAddress("http://" + cameraAddress + "/onvif/device_service");
var httpTransportBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Digest };
var textMessageEncodingBinding = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) };
var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding);
var passwordDigestBehavior = new PasswordDigestBehavior(adminName, adminPassword);
var deviceClient = new DeviceClient(customBinding, endPointAddress);
deviceClient.Endpoint.Behaviors.Add(passwordDigestBehavior);
这篇关于定义DeviceClient(Bind,endPointAddress)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!