Send xml files in android with http post

大城市里の小女人 提交于 2020-01-16 20:01:58

问题


I want to know if anyone knows a good tutorial. I have in my app 2 edittexts with username and password. I want to write these in an xml file and send it to my server. I was thinking about a function which opens the connection, writes the xml, sends it, and waits for an answer, and this function will have two input parameters which are username and password. Please send me code suggestions :-) thanks


回答1:


Your question has been asked before: Android, sending XML via HTTP POST (SOAP) A simple google search of: android http post xml returned that result, of course SO has a search feature too ;)




回答2:


What you want to look at is the HttpClient class. You'll probably want to do something like this:

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.example.com/myscript");
HttpResponse response = httpClient .execute(httpPost );

And add your data using httppost.setEntity. There are plenty of code examples out there for this type of thing. A simple Google search should yield tons of information for you.



来源:https://stackoverflow.com/questions/5582830/send-xml-files-in-android-with-http-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!