ONVIF Authentication in .NET 4.0 with Visual Studios 2010

后端 未结 1 1899
生来不讨喜
生来不讨喜 2020-12-08 11:51

My task is to try to establish a communication with a ONVIF camera in the building to, eventually, upgrade the company\'s domotic solution to automatically recognize ONVIF c

相关标签:
1条回答
  • 2020-12-08 12:46

    All right:

    EndpointAddress serviceAddress = new EndpointAddress("<mycameraurl:<mycameraport>/onvif/device_service");
    
    HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
    
    httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
    
    var messageElement = new TextMessageEncodingBindingElement();
    
    messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);
    
    CustomBinding bind = new CustomBinding(messageElement, 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 for information
    
    client.GetSystemDateAndTime();
    
    client.GetNetworkInterfaces();
    
    client.GetScopes();
    
    client.GetRelayOutputs();
    
    client.GetWsdlUrl();
    

    The problem was that the camera required authentication before giving any information beyond the simplest ones, and the trickiest part was to finally catch a working xml onvif message to recreate it in my own software.

    0 讨论(0)
提交回复
热议问题