Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Post an XML filt to a Web Server

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I'm making a mountain out of a molehill but I just can't get an XML file posted to my web server. I do get a response "BasicHttpResponse@44e809b8". Here's most of my code:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Construct data
String data = null;

HttpClient httpClient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.airdynamite.com/newsql.xml");

try {
InputStream is = null;
is = new BufferedInputStream(new FileInputStream("/data/data/samples.employeedirectory/newsql.xml"));
data = is.toString();

httppost.setEntity(new StringEntity(data, "UTF8"));

HttpResponse response = httpClient.execute(httppost);

Toast.makeText(this, "response "+response, Toast.LENGTH_LONG).show();

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}

Thank you in advance for any suggestions.
 
Saloon Keeper
Posts: 7174
166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"BasicHttpResponse@44e809b8" is not the response you're getting, it's the result of calling "response.toString()" (which is what using "response" in a string concatenation will do).

The actual response can be obtained via "response.getEntity()", and then working with that object.
 
Thomas Francl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. Does the rest of the code appear correct?
 
reply
    Bookmark Topic Watch Topic
  • New Topic