Guest User

Untitled

a guest
May 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public bool Initialise(string cameraAddress, string userName, string password)
  2. {
  3. bool result = false;
  4.  
  5. try
  6. {
  7. var messageElement = new TextMessageEncodingBindingElement()
  8. {
  9. MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)
  10. };
  11.  
  12. HttpTransportBindingElement httpBinding = new HttpTransportBindingElement()
  13. {
  14. AuthenticationScheme = AuthenticationSchemes.Digest
  15. };
  16.  
  17. CustomBinding bind = new CustomBinding(messageElement, httpBinding);
  18.  
  19. System.Net.ServicePointManager.Expect100Continue = false;
  20.  
  21. DeviceClient deviceClient = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));
  22.  
  23. var temps = deviceClient.GetSystemDateAndTime();
  24. }
  25. catch (Exception ex)
  26. {
  27. ErrorMessage = ex.Message;
  28. }
  29. return result;
  30. }
  31.  
  32. deviceClient = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));
  33. deviceClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
  34. deviceClient.ClientCredentials.HttpDigest.ClientCredential.UserName = userName;
  35. deviceClient.ClientCredentials.HttpDigest.ClientCredential.Password = password;
Add Comment
Please, Sign In to add comment