wankeda
昨天 734f49c3f74e4a46cfb5892ce60dbf1bb86e74ab
WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs
@@ -78,19 +78,26 @@
            return null;
        }
        public static string Post(string serviceAddress, string requestJson = null, string contentType = "application/json", Dictionary<string, string>? headers = null)
        public static string Post(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null)
        {
            string result = string.Empty;
            DateTime beginDate = DateTime.Now;
            try
            {
                string result = string.Empty;
                using (HttpContent httpContent = new StringContent(requestJson))
                {
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    using HttpClient httpClient = new HttpClient();
                    httpClient.Timeout = new TimeSpan(0, 0, 60);
                    foreach (var header in headers)
                        httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
                    if (serviceAddress.Contains("cimforce/AtomJsonService"))
                    {
                        httpClient.Timeout = new TimeSpan(0, 0, 30);
                    }
                    if (headers != null)
                    {
                        foreach (var header in headers)
                            httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
                    }
                    result = httpClient.PostAsync(serviceAddress, httpContent).Result.Content.ReadAsStringAsync().Result;
                }
@@ -98,9 +105,12 @@
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new Exception(e.Message);
            }
            return null;
            finally
            {
                //Logger.Add(serviceAddress, requestJson, result, beginDate);
            }
        }
        /// <summary>
        /// post请求