Created
January 14, 2025 23:39
-
-
Save nbxx/3c6491033386b4974173f5f1cc73fb8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BasicHttpBinding binding = (BasicHttpBinding)WcfServiceType.GetBinding(typeof(BasicHttpBinding)); | |
if (this._isSecurity) | |
{ | |
Uri remoteUri = new Uri(string.IsNullOrWhiteSpace(this._remoteUri) ? this._serviceAddress : this._remoteUri); | |
if(remoteUri.Scheme.Equals(Uri.UriSchemeHttp,StringComparison.OrdinalIgnoreCase)) | |
{ | |
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; | |
} | |
if(remoteUri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) | |
{ | |
binding.Security.Mode = BasicHttpSecurityMode.Transport; | |
} | |
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; | |
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; | |
} | |
this._clientProxy = this._clientProxyFactory.GetPerSessionThrowableProxy(binding, string.IsNullOrWhiteSpace(this._remoteUri) ? this._serviceAddress : this._remoteUri); | |
if (this._isSecurity) | |
{ | |
this._clientProxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; | |
this._clientProxy.ClientCredentials.UserName.UserName = this._username; | |
this._clientProxy.ClientCredentials.UserName.Password = this._password; | |
this._clientProxy.SetClientCredentialsAction = i => | |
{ | |
i.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; | |
i.UserName.UserName = this._username; | |
i.UserName.Password = this._password; | |
}; | |
} | |
this._clientProxy.ReceivingReply += (s, e) => this.RaiseEvent(this.ReceivingReply, e); | |
this._clientProxy.SendingRequest += (s, e) => this.RaiseEvent(this.SendingRequest, e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment