3

I'am trying to reach a SOAP API using the HttpClient object. I've searched everywhere but most of the people are using the HttpWebRequest object which is not supported by the DNX Core framework.

Does anyone have a working example of a SOAP request using the HttpClient object?

This image represents a simple request from this API (NuSOAP PHP):

enter image description here

Thank you!

EDIT :

So I was able to call the API with the following code:

        Uri uri = new Uri("http://localhost/teek_api/service.php");

        HttpClient hc = new HttpClient();

        hc.DefaultRequestHeaders.Add("SOAPAction", "http://localhost/teek_api/service.php/ping");
        var content = new StringContent("text/xml; charset=utf-8");

        using (HttpResponseMessage response = await hc.PostAsync(uri, content))
        {
            var soapResponse = await response.Content.ReadAsStringAsync();
            string value = await response.Content.ReadAsStringAsync();


            return value;
        }
Tseng
  • 61,549
  • 15
  • 193
  • 205
Ricardo Mota
  • 1,194
  • 2
  • 12
  • 25

0 Answers0