Exemple #1
0
        internal static Default.Container Context()
        {
            string LogMsg = MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().ToString() + " :: ";

            try
            {
                var container = new Default.Container(new Uri(serviceURI));
                container.Timeout = serviceTimeout;

                container.BuildingRequest += (sender, eventArgs) =>
                {
                    //attach header information required to use ApiKey
                    var hmac = new HMAC()
                    {
                        TimeStamp = DateTime.UtcNow.ToString(),
                        Uri       = eventArgs.RequestUri.ToString(),
                        Method    = eventArgs.Method.ToString(),
                        AppID     = appID,
                        ApiKey    = apiKey
                    };
                    hmac.SetNonce();
                    eventArgs.Headers.Add("HMAC", hmac.BuildHeader());
                    eventArgs.Headers.Add("Hash", hmac.Hash());
                };
                return(container);
            }
            catch (Exception ex)
            {
                NLogWriter.LogMessage(LogType.Error, LogMsg + "Exception calling Flotation Device Service Application :: " + ex.ToString());
                throw;
            }
        }