Beispiel #1
0
        //deprecated asigned for deletion
        public static async Task PushAsync(String msg, ILogger logger)
        {
            try
            {
                HttpClient client = new HttpClient();
                // Update port # in the following line.
                client.BaseAddress = new Uri("http://localhost:" + reader.getValue(PORT_UAS) + "/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = await client.GetAsync($"rest/iot/legacy/" + msg);

                response.EnsureSuccessStatusCode();
                logger.Information("[DEBUG] pushing to:" + "rest/iot/legacy" + msg);
            }
            catch
            {
                logger.Error("REST Connection failed");
            }
        }
Beispiel #2
0
        public static void startRESTService()
        {
            PropertiesFileReader propertyreader = new PropertiesFileReader(HAWCommunicationAgent.CONFIG_PATH);


            UICRestService DemoServices = new UICRestIMPL();
            WebServiceHost _serviceHost = new WebServiceHost(DemoServices,
                                                             new Uri("http://localhost:" + propertyreader.getValue(UIC_PORT)));

            _serviceHost.Open();
            Console.ReadKey();
            _serviceHost.Close();
        }