public static WsSoap CreateWsService(string url = null, int timeoutSeconds = 60) { try { var client = new WsSoapClient(); client.Endpoint.Address = new EndpointAddress(url ?? GlobalVar.ServiceBaseUrl); var userInfo = GlobalVar.UserInfo ?? new UserInfo(); var userInfoJson = CoreConvert.ObjToJson(userInfo); var authorization = CoreEncrypt.AesEncrypt(userInfoJson, GlobalConst.AesKey); client.Endpoint.Behaviors.Add(AuthHelper.CreateAuthHeaderBehavior(authorization)); if (client.Endpoint.Binding == null) { return(client); } client.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 0, 0, timeoutSeconds); client.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, timeoutSeconds); return(client); } catch (Exception e) { CoreLog.Error(e); throw new Exception("服务连接失败"); } }
public static string CreateToken(UserInfo userInfo) { var token = DateTime.UtcNow.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"); return(CoreEncrypt.AesEncrypt(token, CoreEncrypt.Md5(userInfo.UserName))); }