Client
eil_userid = BaseCmConfig.GetCustomSettings ( "EILUserId");
eil_pw = BaseCmConfig.GetCustomSettings ( "EILPassword");
eil_pw = FMSEncrypt.Decrypt (eil_pw);
eil_nc = new NetworkCredential (eil_userid, eil_pw);
eil_url = "https: //" + System.Configuration.ConfigurationManager.AppSettings [ "EILWS"]. ToString ();
eil_credentials eil_nc.GetCredential = (new Uri (eil_url), "Basic");
EILWS.GetAccountInfoBinding not EILWS.GetAccountInfoBinding = new ();
eil.Credentials = eil_credentials;
eil.PreAuthenticate = true;
Server
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
(request as System.Net.HttpWebRequest).KeepAlive = false;
if (PreAuthenticate)
{
NetworkCredential networkCredentials = Credentials.GetCredential(uri, "Basic");
if (networkCredentials != null)
{
byte[] credentialBuffer = new UTF8Encoding().GetBytes(networkCredentials.UserName + ":" + networkCredentials.Password);
request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);
}
else
{
throw new ApplicationException("No network credentials");
}
}
return request;
}