gpt4 book ai didi

c# - '一个 :Action' must be understood but cannot be handled and RequestSecurityToken problem on an ONVIF Camera

转载 作者:行者123 更新时间:2023-11-30 22:39:34 26 4
gpt4 key购买 nike

我正在尝试与 ONVIF 摄像头建立通信,但由于缺乏 Web 服务、ONVIF 和 C# 方面的经验,我遇到了一些我无法完全理解的奇怪错误。我在 .NET 4.0 上并使用 Visual Studios 2010

 EndpointAddress endPointAddress = new EndpointAddress("http://192.168.3.246:80/onvif/device_service");  
WSHttpBinding bind = new WSHttpBinding();
bind.Security.Mode = SecurityMode.Message;
bind.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
DeviceClient temp = new DeviceClient(bind, endPointAddress);
temp.ClientCredentials.UserName.UserName = myusername;
temp.ClientCredentials.UserName.Password = mypassword;
SystemDateTime s = temp.GetSystemDateAndTime();

这会导致崩溃并出现错误“元素‘a:Action’中的数据必须被理解但无法处理”。我尝试手动捕获请求并在关闭 "s:mustUnderstand="1"标志的情况下执行它,但随后我得到一个“Method 't:RequestSecurityToken' not implemented: method name or namespace not recognized"错误。

我的 ONVIF 相机有问题,还是我做错了什么?自 3 天以来,我一直在尝试各种方法来尝试连接到该相机,而不是像 GetSystemDateAndTime() 和 GetDeviceInformation() 这样的简单、不安全的信息,但我我卡住了。

最佳答案

好吧,我希望它最终能帮助其他像我一样陷入困境的人:

HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
var messegeElement = new TextMessageEncodingBindingElement();
messegeElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);
CustomBinding bind = new CustomBinding(messegeElement, httpBinding);

// Add our custom behavior - this require the Microsoft WSE 3.0 SDK
PasswordDigestBehavior behavior = new PasswordDigestBehavior(CameraASCIIStringLogin, CameraASCIIStringPassword);
DeviceClient client = new DeviceClient(bind, serviceAddress);
client.Endpoint.Behaviors.Add(behavior);

// We can now ask informations
client.GetSystemDateAndTime();
client.GetNetworkInterfaces();
client.GetScopes();
client.GetRelayOutputs();
client.GetWsdlUrl();

秘诀是在 messegeElement 中设置正确的信封设置(Soap12 因为我们的相机只支持这个,AdressingVersion.None 删除“mustunderstand”标志)并添加 Microsoft WSE 3.0 作为库,即使我在.NET 4.0 并使用 Visual Studio 2010。这将使您能够使用它们提供的 UserNameToken 函数,而无需自己从头开始重新创建它们。

关于c# - '一个 :Action' must be understood but cannot be handled and RequestSecurityToken problem on an ONVIF Camera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5646534/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com