I created a simple WCF REST service that is returning a list of data
rows from a SQL Server. I've been trying to get my android application
to be able to refernce the returned data for a few days now and
finally feel like I am getting somehwere. The below code is working
and the toast text displays the entire response from the web call in a
comma deliminated format (see bottom for example) but the question is
how I can individually reference each returned item and how can I fill
a listview with the results?

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.runlist);
        //displayRunList(null); //call the displayRunList function on
create
        try {
                //call our rest service call through httpGet
        HttpGet request = new HttpGet("http://www.mydomain.com/webserv/
Service1/getVehicles");
                        request.setHeader("Accept", "application/json");
                        request.setHeader("Content-type", "application/json");
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        HttpResponse response = httpClient.execute(request);
                        HttpEntity entity = response.getEntity();
                        Returned = EntityUtils.toString(entity);
                         Toast.makeText(this, Returned, 
Toast.LENGTH_LONG).show();
                        Log.i("Test",response.getStatusLine().toString());
        } catch (IOException ioe) {
        }
      }
//
**************************************************************END********************************************************

When I run the REST service in browswer I am returned with the
following XML;

- <clsVehicles xmlns="http://schemas.datacontract.org/2004/07/
WcfRestService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance";>
  <carNo>A1</carNo>
  <invNo>262901</invNo>
  <make>FORD</make>
  <mileage>117894</mileage>
  <model>RANGER</model>
  <saleDate>12/30/2011 12:00:00 AM</saleDate>
  <sold>True</sold>
  <style />
  <year>1994</year>
  </clsVehicles>


The Toast text returns the data like this:
{"carNo":"A1", "invNo":"262901", "make":"FORD"...............etc}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to