Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Have anyone ever used ASMX SOAP service in PCL, Please help me out

$
0
0

I am trying to use a ASMX service in PCL based Xamarin.Forms, via various forum posts I came to know that we can't invoke a ASMX Web Service directly however from https://stackoverflow.com/questions/4791794/client-to-send-soap-request-and-received-response [Option-2] I came to know that we can get response using following code:

public async Task CreateSoapEnvelop()
{
string soapString = @<?xml version="1.0"" encoding=""utf-8""?>




";

      HttpResponseMessage response = await PostXmlRequest("your_url_here", soapString);
      string content = await response.Content.ReadAsStringAsync();

  return content;

}

public static async Task PostXmlRequest(string baseUrl, string xmlString)
{
using (var httpClient = new HttpClient())
{
var httpContent = new StringContent(xmlString, Encoding.UTF8, "text/xml");
httpContent.Headers.Add("SOAPAction", "http://tempuri.org/HelloWorld");

      return await httpClient.PostAsync(baseUrl, httpContent);
   }

}

However when I am trying to invoke the service, the application is hangs or become unresponsive.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>