DEV Community

Discussion on: Make SOAP requests using IHttpClientFactory in .NET Core

Collapse
 
datacruze profile image
datacruze

Hi Bojan, nice article. How would I add an X509 certificate to use the soap service with this approach? I currently use the WCF bindings to add the X509 certificate

Collapse
 
nikolicbojan profile image
Bojan Nikolić

Hi, I would suggest that you setup certificate in a constructor of a service, similarly how I setup timeouts here github.com/nikolic-bojan/soap-clie...
Maybe this example could help docs.microsoft.com/en-us/dotnet/fr...

Collapse
 
datacruze profile image
datacruze

Thanks, I added the cert but I still see TIME_WAIT when running netstat. Do you think I did not implement httpmessagehandler correctly? I documented my issue at the link below. Please let me know any suggestions
github.com/dotnet/wcf/issues/4838

Thread Thread
 
nikolicbojan profile image
Bojan Nikolić

Hi @datacruze
I would like to understand this better (checked Issue on GH) - you managed to add certificate and to call WCF service; you also conducted load tests and that was also a success; you load tested with 20 threads in parallel.
HttpMessageHandler has a default 2 minute lifetime, so all your connections should be closed after that period of time.
I checked your code on GH Issue and what I can see is that it is quite different then mine where I inject IHttpMessageHandlerFactory. I am also Closing the channel after success and Aborting on any issue or if it is not a success.
Were all of your calls a success? Could you try to close the Channel each time?

Thread Thread
 
ctechid profile image
Ey

Try to call channel.Abort(), then channel.Close(), channel.Dispose(), channel = null.