G
G
Gotoh2018-11-28 14:18:01
ASP.NET
Gotoh, 2018-11-28 14:18:01

Why is a request not sent to the soap service from asp.net core using httpClient?

I'm trying to send a soap request to a service from asp net core 2.1. I use the following code

HttpContent content = new StringContent(requestXml, Encoding.UTF8);
                content.Headers.ContentType =
                    MediaTypeHeaderValue.Parse(
                        "application/soap+xml;charset=UTF-8;action=\"urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b\"");

                var response = await _client.PostAsync(new Uri("https://ips-test.rosminzdrav.ru/52f0d9db3c8c0"), content);
                var result = await response.Content.ReadAsStringAsync();
                return result;

I get an error: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The server returned an invalid or unrecognized response.
Moreover, if exactly the same code is run in a normal console application on .net, then everything works fine.
At the same time, after receiving an error, even soap ui stops sending a message and crashes with the same error until I restart the computer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gotoh, 2019-04-25
@gotoh

Six months later, I finally found the answer. It was deadlock. Read more here: blog.stephencleary.com/2012/07/dont-block-on-async...
And in my code, I just removed .Result when calling the soap service call method and called this method in the controller via await.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question