Hi,
I have below code which is perfectly working on a Windows Forms application.
I have added Connected Service to my Project as you can see in the attached screenshot and copied the code thinking it will also work without any issue because both are .NET but I ended up with this error:
**Unhandled Exception:
System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Error in deserializing body of request message for operation 'GetMakaniDetails'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetMakaniDetails' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'GetMakaniDetailsAsync' and namespace 'http://tempuri.org/' occurred
**
can any one help please
Here is the code:
MakaniServiceReference.MakaniPublicClient makani;
public class MakaniDetails
{
/// <summary>
/// A User's username. eg: "sergiotapia, mrkibbles, matumbo"
/// </summary>
public string MAKANI { get; set; }
/// <summary>
/// A collection of the User's linked accounts.
/// </summary>
public List<MAKANI_INFO> MAKANI_INFO { get; set; }
}
public class MAKANI_INFO
{
[JsonProperty("COMMUNITY_E")]
public string COMMUNITY_E;
[JsonProperty("COMMUNITY_A")]
public string COMMUNITY_A;
[JsonProperty("ENT_NAME_E")]
public string ENT_NAME_E;
[JsonProperty("ENT_NAME_A")]
public string ENT_NAME_A;
[JsonProperty("ENT_NO")]
public string ENT_NO;
[JsonProperty("BLDG_NAME_E")]
public string BLDG_NAME_E;
[JsonProperty("BLDG_NAME_A")]
public string BLDG_NAME_A;
[JsonProperty("EMIRATE_E")]
public string EMIRATE_E;
[JsonProperty("EMIRATE_A")]
public string EMIRATE_A;
[JsonProperty("LATLNG")]
public string LATLNG;
[JsonProperty("SHORT_URL")]
public string SHORT_URL;
}
private async void get_makani_details()
{
// try
// {
if (!string.IsNullOrWhiteSpace(LabelKidMakani.Text))
{
makani = new MakaniServiceReference.MakaniPublicClient();
string x = await makani.GetMakaniDetailsAsync(LabelKidMakani.Text, "");
var user = JsonConvert.DeserializeObject<MakaniDetails>(x);
if (!string.IsNullOrWhiteSpace(user.MAKANI_INFO[0].COMMUNITY_A)) LabelKidCommunity.Text = user.MAKANI_INFO[0].COMMUNITY_A; else LabelKidCommunity.Text = "";
if (!string.IsNullOrWhiteSpace(user.MAKANI_INFO[0].BLDG_NAME_A)) LabelKidBuilding.Text = user.MAKANI_INFO[0].BLDG_NAME_A; else LabelKidBuilding.Text = "";
if (!string.IsNullOrWhiteSpace(user.MAKANI_INFO[0].ENT_NAME_A)) LabelKidEntrance.Text = user.MAKANI_INFO[0].ENT_NAME_A; else LabelKidEntrance.Text = "";
if (!string.IsNullOrWhiteSpace(user.MAKANI_INFO[0].ENT_NO)) LabelKidEntranceNo.Text = user.MAKANI_INFO[0].ENT_NO; else LabelKidEntranceNo.Text = "";
if (!string.IsNullOrWhiteSpace(user.MAKANI_INFO[0].EMIRATE_A)) LabelKidEmirate.Text = user.MAKANI_INFO[0].EMIRATE_A; else LabelKidEmirate.Text = "";
// var location = user.MAKANI_INFO[0].LATLNG.Split(',');
// address_latitude = double.Parse(location[0]);
// address_longitude = double.Parse(location[1]);
// MapStudent.Location = new Point(address_latitude, address_longitude);
}
// }
/*
catch (Exception ex)
{
Crashes.TrackError(ex, new Dictionary<string, string>
{
{ "Page", "Kid" },
{ "Where", "get_makani_details" }
});
await DisplayAlert("خطأ", "رقم مكاني غير صحيح", "متابعة");
LabelKidCommunity.Text = "";
LabelKidBuilding.Text = "";
LabelKidEntrance.Text = "";
LabelKidEntranceNo.Text = "";
LabelKidEmirate.Text = "";
return;
}
*/
}
Thanks,
Jassim