public PhoneInfo GetPhoneInfo(string state) { //链接远程Webservice ServiceSoapClient.EndpointConfiguration endpoit = new YDService.ServiceSoapClient.EndpointConfiguration(); ServiceSoapClient yDServiceClient = new YDService.ServiceSoapClient(endpoit); //获取远程数据 string result = yDServiceClient.WX_SY_RecerAsync("胜京物流", state).Result.ToString(); //.To_InfoAsync(company, ordernumber).Result.ToString(); PhoneInfo phoneInfo = new PhoneInfo(); result = result.Replace('#', '&'); result = result.Replace("err", "msg"); string[] sArray = result.Split('&'); //数据赋值 foreach (string substr in sArray) { if (!string.IsNullOrWhiteSpace(substr)) { string[] ssArry = substr.Split('='); phoneInfo.GetType().GetProperty(ssArry[0]).SetValue(phoneInfo, ssArry[1]); } } return(phoneInfo); }
/// <summary> /// 链接远程Webservice,获取运单信息,生成对象 /// </summary> /// <param name="name">站点名称</param> /// <param name="company">公司名称</param> /// <param name="ordernumber">运单号码</param> public YdInfo GetRemoteYdInfo(string name, string company, string ordernumber) { //链接远程Webservice ServiceSoapClient.EndpointConfiguration endpoit = new YDService.ServiceSoapClient.EndpointConfiguration(); ServiceSoapClient yDServiceClient = new YDService.ServiceSoapClient(endpoit); //获取远程数据 name = string.IsNullOrWhiteSpace(name) ? "胜京物流" : name; company = string.IsNullOrWhiteSpace(company) ? "胜京物流" : company; string result = yDServiceClient.To_InfoAsync(company, ordernumber).Result.ToString(); //调整返回字符串格式 result = result.Replace('#', '&'); result = result.Replace("err", "msg"); //远程返回结果分割 string[] sArray = result.Split('&'); //新建运单信息 YdInfo ydInfo = new YdInfo(); //数据赋值 foreach (string substr in sArray) { if (!string.IsNullOrWhiteSpace(substr)) { string[] ssArry = substr.Split('='); ydInfo.GetType().GetProperty(ssArry[0]).SetValue(ydInfo, ssArry[1]); } } //返回运单信息 return(ydInfo); }