示例#1
0
        public DeviceViewModel()
        {
            EndpointAddress             DeviceServiceRemoteAddress = new EndpointAddress("http://" + IpAddress + "/onvif/device_service");
            HttpTransportBindingElement httpBinding = new HttpTransportBindingElement
            {
                AuthenticationScheme = AuthenticationSchemes.Digest
            };
            var messageElement = new TextMessageEncodingBindingElement
            {
                MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
            };
            CustomBinding bind = new CustomBinding(messageElement, httpBinding);

            Client = new DeviceClient(bind, DeviceServiceRemoteAddress);

            PasswordDigestBehavior passwordDigestBehavior = new PasswordDigestBehavior(Username, Password);

            Client.Endpoint.Behaviors.Add(passwordDigestBehavior);



            Client.GetDeviceInformation(out string Model, out string FirmwareVersion, out string SerialNumber, out string HardwareId);

            Console.WriteLine("Model = " + Model);
            Console.WriteLine("FirmwareVersion = " + FirmwareVersion);
            Console.WriteLine("SerialNumber = " + SerialNumber);
            Console.WriteLine("HardwareId = " + HardwareId);
        }
示例#2
0
        public DeviceViewModel()
        {
            string[] arguments = Environment.GetCommandLineArgs();
            if (arguments.Length > 1)
            {
                IpAddress = arguments[1];
            }
            if (arguments.Length > 2)
            {
                Username = arguments[2];
            }
            if (arguments.Length > 3)
            {
                Password = arguments[3];
            }
            Console.WriteLine("Querying " + IpAddress + " ...");

            /* replace the two lines below by the following version if you want to use HTTPS
             *   EndpointAddress DeviceServiceRemoteAddress = new EndpointAddress("http://" + IpAddress + "/onvif/device_service");
             *   var httpBinding = new HttpTransportBindingElement
             */
            EndpointAddress DeviceServiceRemoteAddress = new EndpointAddress("http://" + IpAddress + "/onvif/device_service");
            var             httpBinding = new HttpTransportBindingElement
            {
                AuthenticationScheme = AuthenticationSchemes.Digest
            };
            var messageElement = new TextMessageEncodingBindingElement
            {
                MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
            };
            CustomBinding bind = new CustomBinding(messageElement, httpBinding);

            Client = new DeviceClient(bind, DeviceServiceRemoteAddress);

            PasswordDigestBehavior passwordDigestBehavior = new PasswordDigestBehavior(Username, Password);

            Client.Endpoint.Behaviors.Add(passwordDigestBehavior);

            string Model, FirmwareVersion, SerialNumber, HardwareId;

            Client.GetDeviceInformation(out Model, out FirmwareVersion, out SerialNumber, out HardwareId);

            Console.WriteLine("Model = " + Model);
            Console.WriteLine("FirmwareVersion = " + FirmwareVersion);
            Console.WriteLine("SerialNumber = " + SerialNumber);
            Console.WriteLine("HardwareId = " + HardwareId);
        }