public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = enterpriseServerUrl.Trim(); if (serverUrl.Length == 0) { throw new Exception("Enterprise Server URL could not be empty"); } int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (!String.IsNullOrEmpty(username)) { // create assertion UsernameAssertion assert = new UsernameAssertion(username, password); // apply policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = _serverUrl.Trim(); if (serverUrl.Length == 0) { throw new Exception("Enterprise Server URL could not be empty"); } int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (_securityPolicy != null) { proxy.SetPolicy(_securityPolicy); } }
public static void ApplyAutheticationTicket(WebServicesClientProtocol protocol, string userName, string password) { UsernameToken token = GetUsernameToken(userName, password, PasswordOption.SendPlainText); protocol.SetClientCredential(token); protocol.SetPolicy(new TpPolicy()); }
/// <summary> /// 对某个WS进行初始化 /// </summary> /// <param name="ws"></param> /// <param name="username"></param> /// <param name="password"></param> public static void Init(WebServicesClientProtocol ws, string username, string password) { AppContext.UserName = username; AppContext.Password = password; Policy policy = new Policy(); policy.Assertions.Add(new MyAssertion()); ws.SetPolicy(policy); }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = _serverUrl.Trim(); if (serverUrl.Length == 0) throw new Exception("Enterprise Server URL could not be empty"); int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (_securityPolicy != null) proxy.SetPolicy(_securityPolicy); }
public void Configure(WebServicesClientProtocol proxy) { // configure proxy URL if (!String.IsNullOrEmpty(serverUrl)) { if (serverUrl.EndsWith("/")) serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); proxy.Url = serverUrl + proxy.Url.Substring(proxy.Url.LastIndexOf('/')); } // set proxy timeout proxy.Timeout = (timeout == -1) ? System.Threading.Timeout.Infinite : timeout * 1000; // setup security assertion if (!String.IsNullOrEmpty(serverPassword)) { ServerUsernameAssertion assert = new ServerUsernameAssertion(ServerSettings.ServerId, serverPassword); // create policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } // provider settings ServiceProviderSettingsSoapHeader settingsHeader = new ServiceProviderSettingsSoapHeader(); List<string> settings = new List<string>(); // AD Settings settings.Add("AD:Enabled=" + ServerSettings.ADEnabled.ToString()); settings.Add("AD:AuthenticationType=" + ServerSettings.ADAuthenticationType.ToString()); settings.Add("AD:RootDomain=" + ServerSettings.ADRootDomain); settings.Add("AD:Username="******"AD:Password="******"Server:ServerId=" + ServerSettings.ServerId); settings.Add("Server:ServerName=" + ServerSettings.ServerName); // Provider Settings settings.Add("Provider:ProviderGroupID=" + ProviderSettings.ProviderGroupID.ToString()); settings.Add("Provider:ProviderCode=" + ProviderSettings.ProviderCode); settings.Add("Provider:ProviderName=" + ProviderSettings.ProviderName); settings.Add("Provider:ProviderType=" + ProviderSettings.ProviderType); // Custom Provider Settings foreach (string settingName in ProviderSettings.Settings.Keys) { settings.Add(settingName + "=" + ProviderSettings.Settings[settingName]); } // set header settingsHeader.Settings = settings.ToArray(); FieldInfo field = proxy.GetType().GetField("ServiceProviderSettingsSoapHeaderValue"); if (field != null) field.SetValue(proxy, settingsHeader); }
public void Configure(WebServicesClientProtocol proxy) { // set proxy URL string serverUrl = enterpriseServerUrl.Trim(); if (serverUrl.Length == 0) throw new Exception("Enterprise Server URL could not be empty"); int idx = proxy.Url.LastIndexOf("/"); // strip the last slash if any if (serverUrl[serverUrl.Length - 1] == '/') serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); proxy.Url = serverUrl + proxy.Url.Substring(idx); // set timeout proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite; if (!String.IsNullOrEmpty(username)) { // create assertion UsernameAssertion assert = new UsernameAssertion(username, password); // apply policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } }
public void Configure(WebServicesClientProtocol proxy) { // configure proxy URL if (!String.IsNullOrEmpty(serverUrl)) { if (serverUrl.EndsWith("/")) { serverUrl = serverUrl.Substring(0, serverUrl.Length - 1); } proxy.Url = serverUrl + proxy.Url.Substring(proxy.Url.LastIndexOf('/')); } // set proxy timeout proxy.Timeout = (timeout == -1) ? System.Threading.Timeout.Infinite : timeout * 1000; // setup security assertion if (!String.IsNullOrEmpty(serverPassword)) { ServerUsernameAssertion assert = new ServerUsernameAssertion(ServerSettings.ServerId, serverPassword); // create policy Policy policy = new Policy(); policy.Assertions.Add(assert); proxy.SetPolicy(policy); } // provider settings ServiceProviderSettingsSoapHeader settingsHeader = new ServiceProviderSettingsSoapHeader(); List <string> settings = new List <string>(); // AD Settings settings.Add("AD:Enabled=" + ServerSettings.ADEnabled.ToString()); settings.Add("AD:AuthenticationType=" + ServerSettings.ADAuthenticationType.ToString()); settings.Add("AD:RootDomain=" + ServerSettings.ADRootDomain); settings.Add("AD:Username="******"AD:Password="******"Server:ServerId=" + ServerSettings.ServerId); settings.Add("Server:ServerName=" + ServerSettings.ServerName); // Provider Settings settings.Add("Provider:ProviderGroupID=" + ProviderSettings.ProviderGroupID.ToString()); settings.Add("Provider:ProviderCode=" + ProviderSettings.ProviderCode); settings.Add("Provider:ProviderName=" + ProviderSettings.ProviderName); settings.Add("Provider:ProviderType=" + ProviderSettings.ProviderType); // Custom Provider Settings foreach (string settingName in ProviderSettings.Settings.Keys) { settings.Add(settingName + "=" + ProviderSettings.Settings[settingName]); } // set header settingsHeader.Settings = settings.ToArray(); FieldInfo field = proxy.GetType().GetField("ServiceProviderSettingsSoapHeaderValue"); if (field != null) { field.SetValue(proxy, settingsHeader); } }
public static void ApplyAutheticationTicket(WebServicesClientProtocol protocol, string userName, string password) { var token = GetUsernameToken(userName, password, PasswordOption.SendPlainText); protocol.SetClientCredential(token); protocol.SetPolicy(new TpServicePolicy()); }