using System; using System.Collections.Generic; using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; namespace GetHttpData.SDK { public class HttpDataHelper { #region 方法 -> 通过Json方式添加数据(传输) /// /// 通过Json方式添加数据 /// Mr.Cai 2018-1-3 /// /// 完整请求地址 /// 接口名字 /// 表名 /// 授权码 /// json参数数组 /// 其它参数 /// 超时时间 /// public static string InsertDataByJson(string ipAddress, string interfaceName, string tableName, string code, string jsonString, string orderString = "",int outTime = 60) { if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(interfaceName) || string.IsNullOrEmpty(tableName) || string.IsNullOrEmpty(jsonString)) { throw new Exception("请求地址、接口名、表名或请求参数不可为空!"); } try { //string[] args = { code, tableName, josnString, orderString }; //return WSHelper.InvokeWebService(ipAddress, interfaceName, args).ToString(); System.Collections.Hashtable hashtable = new System.Collections.Hashtable { { "code", code}, { "tableName" , tableName}, { "jsonString" , jsonString}, {"orderString" , orderString } }; return ESSupport.Lib.SoapWSHelper.QuerySoapWebServiceString(ipAddress, interfaceName, hashtable, outTime); } catch (Exception ex) { throw new Exception("网络请求失败:" + ex.ToString()); } } #endregion #region 方法 -> 通过Json方式添加数据(对外) /// /// 通过Json方式添加数据 /// Mr.Cai 2018-1-3 /// /// 请求地址 /// 接口名字 /// 授权码 /// json参数数组 /// public static string InsertDataByJson(string ipAddress, string interfaceName, string code, string jsonString) { if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(interfaceName) || string.IsNullOrEmpty(jsonString)) { return "请求地址、接口名或请求参数不可为空!"; } try { string[] args = { code, jsonString }; string _ServiceUrl = string.Format("http://{0}/TableDataService/Service.asmx", ipAddress); return WSHelper.InvokeWebService(_ServiceUrl, interfaceName, args).ToString(); } catch (Exception ex) { return "网络请求失败:" + ex.ToString(); } } #endregion } }