aspose file tools*
The moose likes Android and the fly likes Post an XML filt to a Web Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Post an XML filt to a Web Server" Watch "Post an XML filt to a Web Server" New topic
Author

Post an XML filt to a Web Server

Thomas Francl
Greenhorn

Joined: Nov 12, 2011
Posts: 2
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.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
"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

Joined: Nov 12, 2011
Posts: 2
Thank you. Does the rest of the code appear correct?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Post an XML filt to a Web Server