Good Day All
i am consuming a Wcf service from Android. i am a bit new to Android Dev most of my problems i was able to resolve. this one caught me off guard. My wcf service is defined as follows
and my Memember datacontract class is defined like this
and my ServiceContract looks like this
and i am consuming this in my Adroid app like this
i get an Error on the Following line
and the Error is
I have looked at the my Wcf service, i used the wcftestclient to test the public url and it brings that one item in the list.
Thanks for your Help in Advance
i am consuming a Wcf service from Android. i am a bit new to Android Dev most of my problems i was able to resolve. this one caught me off guard. My wcf service is defined as follows
Code:
public List<MemberModel> Helloworld(string number)
{
List<MemberModel> lstnames = new List<MemberModel>();
MemberModel model = new MemberModel();
model.MEMBER_NAME = "Vuyiswa";
lstnames.Add(model);
return lstnames;
}
and my Memember datacontract class is defined like this
Code:
[DataContract]
public class MemberModel
{
private string _MEMBER_NAME;
[DataMember(Name = "MEMBER_NAME")]
public string MEMBER_NAME
{
get
{
return _MEMBER_NAME;
}
set
{
_MEMBER_NAME = value;
}
}
}
and my ServiceContract looks like this
Code:
[DataContract]
public class MemberModel
{
private string _MEMBER_NAME;
[DataMember(Name = "MEMBER_NAME")]
public string MEMBER_NAME
{
get
{
return _MEMBER_NAME;
}
set
{
_MEMBER_NAME = value;
}
}
}
and i am consuming this in my Adroid app like this
Code:
public void getWcfService() throws ClientProtocolException, IOException, JSONException
{
TextView textView1 = (TextView)findViewById(R.id.textView1);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(SERVICE_URI + "/Helloworld/1");
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
// Read response data into buffer
char[] buffer = new char[(int)responseEntity.getContentLength()];
InputStream stream = responseEntity.getContent();
InputStreamReader reader = new InputStreamReader(stream);
reader.read(buffer);
stream.close();
JSONObject MemberModel = new JSONObject(new String(buffer));
textView1.setText(MemberModel.getString("MEMBER_NAME"));
}
i get an Error on the Following line
Code:
JSONObject MemberModel = new JSONObject(new String(buffer));
and the Error is
Code:
org.json.JSONException: End of input at character 0 of
I have looked at the my Wcf service, i used the wcftestclient to test the public url and it brings that one item in the list.
Thanks for your Help in Advance