gpt4 book ai didi

c# - 使用轴摄像机 P1344 c# 进行 Onvif 身份验证

转载 作者:行者123 更新时间:2023-12-02 01:49:17 25 4
gpt4 key购买 nike

我完全无法使用 ONVIF 身份验证。我想我已经尝试了所有方法,或者至少尝试了几乎所有方法,但我在互联网上找不到足够的信息。我已经使用 svcutil 创建了 stub 客户端,我进行身份验证的代码是(其中之一,因为我已经尝试了很多事情):

 string uri = "http://140.0.22.39/onvif/services";

EndpointAddress serviceAddressPrueba = new EndpointAddress(uri);
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
var messegeElement = new TextMessageEncodingBindingElement();
messegeElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);
CustomBinding bindprueba = new CustomBinding(messegeElement, httpBinding);
DeviceClient clientprueba = new DeviceClient(bindprueba, serviceAddressPrueba);
string passwordDigestBase64;
//HERE I PUT THE CODE TO ENCRYPT THE PASSWORD.
PasswordDigestBehavior behavior1 = new PasswordDigestBehavior("root",passwordDigestBase64);
clientprueba.Endpoint.Behaviors.Add(behavior1);
string d1;
string d2;
string d3;
string d4;

clientprueba.GetDeviceInformation(out d1, out d2, out d3, out d4);

之后出现以下错误:

{"The remote server returned an unexpected response: (400) Bad Request."}

如果您能帮助我提供任何信息来解决此问题,我将非常非常感激。

最佳答案

试试这个方法:

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);

请注意,将 ServicePointManager.Expect100Continue 设置为 false 非常重要。

关于c# - 使用轴摄像机 P1344 c# 进行 Onvif 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8445365/

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