Click here to Skip to main content
15,895,462 members
Home / Discussions / Mobile
   

Mobile

 
AnswerRe: write Once run anywhere for Mobile Application Pin
loctrice14-May-12 9:48
professionalloctrice14-May-12 9:48 
AnswerRe: write Once run anywhere for Mobile Application Pin
RobCroll15-May-12 16:56
RobCroll15-May-12 16:56 
GeneralRe: write Once run anywhere for Mobile Application Pin
Albert Holguin4-Jun-12 8:30
professionalAlbert Holguin4-Jun-12 8:30 
QuestionMobile Develop help ! Pin
doxari11-May-12 19:05
doxari11-May-12 19:05 
QuestionAndroid backup Pin
loctrice10-May-12 4:56
professionalloctrice10-May-12 4:56 
QuestionAdd remove local notification badge. Pin
Valiyamattom26-Apr-12 19:02
Valiyamattom26-Apr-12 19:02 
QuestionHow to add Airplay button to iphone application? Pin
subbaratnam24-Apr-12 22:41
subbaratnam24-Apr-12 22:41 
QuestionError while Accessing a WCF Service in Android Pin
Vimalsoft(Pty) Ltd22-Apr-12 7:23
professionalVimalsoft(Pty) Ltd22-Apr-12 7:23 
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

C#
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

C#
[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


C#
    [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



Java
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


C#
JSONObject MemberModel = new JSONObject(new String(buffer));


and the Error is

C#
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
Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com

AnswerRe: Error while Accessing a WCF Service in Android Pin
RobCroll7-May-12 17:22
RobCroll7-May-12 17:22 
GeneralRe: Error while Accessing a WCF Service in Android Pin
Member 844263528-May-12 21:14
Member 844263528-May-12 21:14 
QuestionJQuery , SharePoint 2010 and Mobile Pin
Madhura Kittur18-Apr-12 8:29
Madhura Kittur18-Apr-12 8:29 
Questionconnecting android app to server Pin
williamroma17-Apr-12 23:23
williamroma17-Apr-12 23:23 
AnswerRe: connecting android app to server Pin
parths19-Apr-12 3:35
parths19-Apr-12 3:35 
QuestionWPF C# - Get Images Off Windows Phone 7 Pin
Kevin Marois16-Apr-12 6:27
professionalKevin Marois16-Apr-12 6:27 
AnswerRe: WPF C# - Get Images Off Windows Phone 7 Pin
Jeremy Hutchinson30-Apr-12 6:44
professionalJeremy Hutchinson30-Apr-12 6:44 
QuestionWP7 RDP protocol Pin
juste_3al_faza16-Apr-12 1:11
juste_3al_faza16-Apr-12 1:11 
QuestionSetting APN programmatically Pin
MitchG92_2416-Apr-12 0:13
MitchG92_2416-Apr-12 0:13 
QuestionCannot open a project / CE 5.0 Pin
biop.codeproject12-Apr-12 18:25
biop.codeproject12-Apr-12 18:25 
QuestionCharging problem on Sansung Omnia i900. Pin
Brady Kelly11-Apr-12 3:09
Brady Kelly11-Apr-12 3:09 
AnswerRe: Charging problem on Sansung Omnia i900. Pin
RobCroll13-Apr-12 5:03
RobCroll13-Apr-12 5:03 
GeneralRe: Charging problem on Sansung Omnia i900. Pin
Brady Kelly13-Apr-12 5:30
Brady Kelly13-Apr-12 5:30 
GeneralRe: Charging problem on Sansung Omnia i900. Pin
Eytukan3-May-12 0:24
Eytukan3-May-12 0:24 
Questionhow to integrate web application to Mobile application Pin
Narendrakumar Arya8-Apr-12 20:07
Narendrakumar Arya8-Apr-12 20:07 
AnswerRe: how to integrate web application to Mobile application Pin
nathadale14-Apr-12 18:29
nathadale14-Apr-12 18:29 
QuestionConnect commercial printer with android Pin
kaushik24026-Apr-12 20:19
kaushik24026-Apr-12 20:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.