public static void MuestraInfo(string uri) { System.DateTime UTCTime = System.DateTime.UtcNow; Console.Write(string.Format("Client UTC Time: {0}", UTCTime.ToString("HH:mm:ss"))); HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); var httpTransportBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Digest }; var textMessageEncodingBinding = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) }; var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding); EndpointAddress serviceAddress = new EndpointAddress(uri); var passwordDigestBehavior = new PasswordDigestBehavior("julian", "julian"); var deviceClient = new DeviceClient(customBinding, serviceAddress); deviceClient.Endpoint.Behaviors.Add(passwordDigestBehavior); Console.Write(" GetHostname: " + deviceClient.GetHostname().Name); var unitTime = deviceClient.GetSystemDateAndTime(); Console.Write((string.Format(" Camera UTC Time: {0}:{1}:{2}", unitTime.UTCDateTime.Time.Hour, unitTime.UTCDateTime.Time.Minute, unitTime.UTCDateTime.Time.Second))); CapabilityCategory[] cc = new CapabilityCategory[100]; deviceClient.GetCapabilities(cc); Console.Write(" GetHostname: " + deviceClient.GetHostname().Name); Console.Write(" GetWsdlUrl: " + deviceClient.GetWsdlUrl()); string model, firmwareVersion, serialNumber, hardwareId; deviceClient.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId); Console.Write(" Model: " + model); Console.Write(" firmwareVersion: " + firmwareVersion); Console.Write(" serialNumber: " + serialNumber); Console.WriteLine("hardwareId: " + hardwareId + "\n\n"); }
void GetHostname2() { try { DeviceClient client = new DeviceClient(new HttpBinding(new IChannelController[] { _listener }), new EndpointAddress(tbAddress.Text)); client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, 0, int.Parse(tbTimeout.Text)); HostnameInformation info = null; try { info = client.GetHostname(); } catch (Exception exc) { BeginInvoke(new Action(() => { ReportError(exc); })); } try { info = client.GetHostname(); } catch (Exception exc) { BeginInvoke(new Action(() => { ReportError(exc); })); } info = client.GetHostname(); } catch (Exception exc) { BeginInvoke(new Action(() => { ReportError(exc); })); } finally { StopAnimation(); } }
public static string GetHostname(Structures set) { var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "/onvif/Device"); DeviceClient client = new DeviceClient(bind, mediaAddress); client.ClientCredentials.UserName.UserName = set.Login; client.ClientCredentials.UserName.Password = set.Password; var t = client.GetHostname().Name; return(t); }
static void Main(string[] args) { Console.Out.WriteLine("Testing custom Http From Imported Files Generated By SvcUtil."); DeviceClient client = new DeviceClient(new CustomHttpBinding(true), new EndpointAddress("http://192.168.3.144:80/onvif/device_service")); //DeviceClient client = new DeviceClient(new CustomHttpBinding(true), new EndpointAddress("http://localhost:27468/Dut.asmx")); try { HostnameInformation info = client.GetHostname(); Console.WriteLine("HostnameInformation.Name: {0}", info.Name); Console.WriteLine("---------------------------------------------------"); try { NTPInformation ntp = client.GetNTP(); Console.WriteLine("NTPInformation.FromDHCP: {0}", ntp.FromDHCP); } catch (Exception exc) { Console.WriteLine(exc.Message); } Console.WriteLine("OK"); //client.BeginGetHostname(new AsyncCallback(GetHostnameCallback), client); } catch (Exception exc) { client.Abort(); Console.WriteLine(exc.Message); //throw; } Console.Out.WriteLine("Press <ENTER> to complete test."); Console.In.ReadLine(); }
public string GetHostname() { var hostname = CallCamera(() => deviceClient.GetHostname()); return(hostname.Name); }