We're trying to connect from a Backendservice made with NET Core 3.1 to a legacy WCF Service. For this we use the two NuGet packages "System.ServiceModel.Http" and "System.ServiceModel.Primitives" (latest version 4.8.1).
For the connection to the endpoint we create the binding/serviceclient manual as follows
var binding = new BasicHttpsBinding();
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
binding.Security.Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Certificate, ProxyCredentialType = HttpProxyCredentialType.Basic };
binding.CloseTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.OpenTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.SendTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.MaxReceivedMessageSize = 2147483646;
binding.MaxBufferSize = 2147483646;
var channelfactory = new SearchServiceClient(binding, endpoint);
channelfactory.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName, "CERTIFICATENAME");
var response = await channelfactory.existsAsync(...);
In order to establish the connection we need to use an SSL client certificate, not a username/password.
With each request we receive the following error message: "The remote server returned an error: (417) Expectation Failed".
I did some research and found out that all you need to do is set the "ExpectContinue" flag to false.
Unfortunately this does not work via the ServicePointManager (not even in web.config).
ServicePointManager.Expect100Continue = false;
if I downgrade the nuget package version of "System.ServiceModel.Http" and "System.ServiceModel.Primitives" to 4.4.4, it works.
Does anyone know how I can do this with the latest version ?
question from:
https://stackoverflow.com/questions/65940536/wcf-the-remote-server-returned-an-error-417-expectation-failed 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…