c# - Asp.net core, HttpClient to reach SOAP service with POST request -


i'm trying reach 3rd party soap ws using httpclient.

[httpget] public iactionresult login() {   httpclienthandler httpclienthandler = new httpclienthandler();   httpclienthandler.servercertificatecustomvalidationcallback = (message, cert, chain, errors) => { return true; };   httpclient client = new httpclient(httpclienthandler);   httprequestmessage request = new httprequestmessage(new httpmethod("post"), myurl);   request.content = new stringcontent(myxmlstring, encoding.utf8, "text/xml");   request.headers.add("soapaction",https://actionnameofws);   httpresponsemessage response = client.sendasync(request).result;   if(response.statuscode == httpstatuscode.ok) return new okresult();   else return new objectresult(response.statuscode); } 

at point breaks taskcanceledexception: task canceled, not task cancel, connection timeout. can send same post request on https soap ui fine, connection ws not problem. can send post request on http code above fine. once i'm trying code above send post on https, i'm getting connection timeout. so, where's catch?

my environment is: os: linux mint 16.04 .net core: 1.0.1

you may mixing async , blocking calls. .result blocking call can lead deadlocks may causing timeout when mixed async calls. make calling action async way through.

[httpget] public async task<iactionresult> login() {     var httpclienthandler = new httpclienthandler();     httpclienthandler.servercertificatecustomvalidationcallback = (message, cert, chain, errors) => { return true; };     var client = new httpclient(httpclienthandler);     client.timeout = timespan.fromseconds(90);     var request = new httprequestmessage(httpmethod.post, myurl);     request.content = new stringcontent(myxmlstring, encoding.utf8, "text/xml");     request.headers.add("soapaction", https://actionnameofws);     var response = await client.sendasync(request);     if(response.statuscode == httpstatuscode.ok) return ok();     else return statuscode((int)response.statuscode); } 

i suggest inspect raw request being sent , response.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -