Using Webservices In Android
I have the following site http://www.freewebservicesx.com/GoldSpotPrice.aspx which provides a webservice api. As i am extremely new to soap and rest i have absolutely no clue abou
Solution 1:
You can make HTTP requests using either HttpURLConnection
or HttpClient. Example of using HttpClient
for a RESTful web service:
HttpClienthttpClient=newDefaultHttpClient();
HttpGethttpGet=newHttpGet("http://www.mywebsite.com/webservice");
HttpResponseresponse= httpClient.execute(httpGet);
StatusLinestatusLine= response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
HttpEntityentity= response.getEntity();
ByteArrayOutputStreamout=newByteArrayOutputStream();
entity.writeTo(out);
out.close();
StringresponseStr= out.toString();
// process response
} else {
// handle bad response
}
Otherwise, if you're working with a SOAP web service, I would recommend using ksoap2
Solution 2:
Use the following url to refer:::
Using ksoap2 for android, and parsing output data...
ksoap2-android - HowToUse.wiki.....
Use this LINK it has a sample the suits your requirement.
also LINK
Post a Comment for "Using Webservices In Android"