Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am trying to consume a government web service to get address details.

I tried below code but it returns nothing although it works fine when I try it on my WinForm when using Add Web Service

A sample valid number is mention in the attached project

1923578758


What I have tried:

Here is a sample project:

https://www.jassimrahma.net/temp/XamarinMakani.zip[^]

and The code I tried is here:

I tried below but did not work:

private string ConstructSoapRequest(string a, string b)
{
    return String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
    <s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">
        <s:Body>
            <Add xmlns=""http://CalculatorService/"">
                <a>{0}</a>
                {1}
            </Add>
        </s:Body>
    </s:Envelope>", a, b);
}

private async void GetMakani()
{
    var soapString = this.ConstructSoapRequest(EntryMakaniNumber.Text, "");

    string url = "https://www.makani.ae/MakaniPublicDataService/MakaniPublic.svc?singleWsdl";

    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("SOAPAction", url);

        var content = new StringContent(soapString, Encoding.UTF8, "text/xml");

        using (var response = await client.PostAsync("https://www.makani.ae/MakaniPublicDataService/MakaniPublic.svc?singleWsdl", content))
        {
            var soapResponse = await response.Content.ReadAsStringAsync();

            System.Diagnostics.Debug.WriteLine("MAKANI RESPONSE");
            System.Diagnostics.Debug.WriteLine("---------------");
            System.Diagnostics.Debug.WriteLine(soapResponse);
            System.Diagnostics.Debug.WriteLine("---------------");
            System.Diagnostics.Debug.WriteLine("MAKANI RESPONSE");
        }
    }

    LabelLatitude.Text = "Latitude: ";
    LabelLongitude.Text = "Longitude: ";
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900