Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7935535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:57:07+00:00 2026-06-03T21:57:07+00:00

My system based on an android client and a wcf – rest – web

  • 0

My system based on an android client and a wcf – rest – web service.
I’m using this tutorial: http://fszlin.dymetis.com/post/2010/05/10/Comsuming-WCF-Services-With-Android.aspx
I’m having a weird problem. I have a valid JSON string (checked it with online tools), the reading to the buffer goes well but when I’m trying to create a JSON array it throws JSONException without an exception variable (the variable is NULL – never happend to me before)
The line that throws the excption:

    request.setHeader("Accept", "application/json");
            request.setHeader("Content-type", "application/json");

            DefaultHttpClient httpClient = new DefaultHttpClient();
            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();

            JSONArray plates = new JSONArray(new String(buffer));

the last line throws the exception.

The text from the service is this:
[{“dtFromDate”:”1899-12-30 20:00:00″,”fBuyWindow”:120,”fNewPrice”:150,”fOldPrice”:400,”lLatitude”:32.021327,”lLongitude”:34.776452,”nDestinatedPlatform”:1,”nMessageID”:1,”nRange”:5,”nStickingHours”:48,”strDetailedDescription”:”נעלי נייק מסוג N95, הנעליים של לאונל מסי, בהנחה מטורפת.”,”strDisplayAddress”:”חנקין 49, חולון”,”strFullAddress”:”חנקין 49, חולון, ישראל”,”strImagePath”:”http://images.free-extras.com/pics/n/nike_swoosh-703.jpg”,”strItemDescrpition”:”נעלי נייק דגם N95 לבן”,”strThumbPath”:”http://images.free-extras.com/pics/n/nike_swoosh-703.jpg”,”strTitle”:”נייק קניון חולון”},{“dtFromDate”:”1899-12-30 20:00:00″,”fBuyWindow”:120,”fNewPrice”:150,”fOldPrice”:400,”lLatitude”:32.021327,”lLongitude”:34.776452,”nDestinatedPlatform”:1,”nMessageID”:2,”nRange”:5,”nStickingHours”:48,”strDetailedDescription”:”נעלי נייק מסוג N95, הנעליים של לאונל מסי, בהנחה מטורפת.”,”strDisplayAddress”:””,”strFullAddress”:”חנקין 49, חולון, ישראל”,”strImagePath”:””,”strItemDescrpition”:”נעלי נייק דגם N95 לבן”,”strThumbPath”:””,”strTitle”:”נייק קניון חולון”},{“dtFromDate”:”1899-12-30 20:00:00″,”fBuyWindow”:120,”fNewPrice”:150,”fOldPrice”:400,”lLatitude”:32.021327,”lLongitude”:34.776452,”nDestinatedPlatform”:1,”nMessageID”:3,”nRange”:5,”nStickingHours”:48,”strDetailedDescription”:”נעלי נייק מסוג N95, הנעליים של לאונל מסי, בהנחה מטורפת.”,”strDisplayAddress”:””,”strFullAddress”:”חנקין 49, חולון, ישראל”,”strImagePath”:””,”strItemDescrpition”:”נעלי נייק דגם N95 לבן”,”strThumbPath”:””,”strTitle”:”נייק קניון חולון”},{“dtFromDate”:”1899-12-30 20:00:00″,”fBuyWindow”:120,”fNewPrice”:150,”fOldPrice”:400,”lLatitude”:32.021327,”lLongitude”:34.776452,”nDestinatedPlatform”:1,”nMessageID”:4,”nRange”:5,”nStickingHours”:48,”strDetailedDescription”:”נעלי נייק מסוג N95, הנעליים של לאונל מסי, בהנחה מטורפת.”,”strDisplayAddress”:””,”strFullAddress”:”חנקין 49, חולון, ישראל”,”strImagePath”:””,”strItemDescrpition”:”נעלי נייק דגם N95 לבן”,”strThumbPath”:””,”strTitle”:”נייק קניון חולון”},{“dtFromDate”:”1899-12-30 20:00:00″,”fBuyWindow”:120,”fNewPrice”:150,”fOldPrice”:400,”lLatitude”:32.021327,”lLongitude”:34.776452,”nDestinatedPlatform”:1,”nMessageID”:5,”nRange”:5,”nStickingHours”:48,”strDetailedDescription”:”נעלי נייק מסוג N95, הנעליים של לאונל מסי, בהנחה מטורפת.”,”strDisplayAddress”:””,”strFullAddress”:”חנקין 49, חולון, ישראל”,”strImagePath”:””,”strItemDescrpition”:”נעלי נייק דגם N95 לבן”,”strThumbPath”:””,”strTitle”:”נייק קניון חולון”}]

Any suggestions?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:57:08+00:00Added an answer on June 3, 2026 at 9:57 pm

    Try the following.

    Change this line…

    char[] buffer = new char[(int)responseEntity.getContentLength()];
    

    …to use a byte array as follows…

    byte[] buffer = new byte[(int)responseEntity.getContentLength()];
    

    You’ll have to forget about using InputStreamReader as it only works with char[]. Instead read the stream using…

    stream.read(buffer);
    

    Then change this line…

    JSONArray plates = new JSONArray(new String(buffer));
    

    …to this to create a UTF-8 encoded String…

    JSONArray plates = new JSONArray(new String(buffer, "UTF-8"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The bugzilla (perl-based) system has a feature to login automatically by using a http
For a 2D game I'm making (for Android) I'm using a component-based system where
We're building an n-tier system based on WCF (but not Entity Framework) and we've
I want to secure a new client server system based on spring with spring-security
I got some issue with parsing, when I PHP based web service. I got
I am working on an Android phone based on the Linux Kernel. I'm using
I'm using the Twitter oAuth system for an app of mine, specifically folllowing this
Were looking into Android for writing a tablet based system. Part of the design
I'm interested in using Android for a E-Ink based platform. I know it has
I'm trying to learn Html5-based web application development on android OS. But what confuses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.