Webservice is totally the part of the APP, summarizing webservice is a site that is used only for the transmission of data via HTTP in a structured way, for example Json or XML instead of HTML, knowing this then your APP will access that site without needing the web browser and so it will be the communication, both sending POST / PUT and getting data like GET . We can use REST or SOAP, which are nothing more than two different formats, in case you are likely to prefer REST, read about it at:
To create the webservice does not need Eclipse, it does not really create anything it is just an IDE to facilitate, in the webservice you do not expose the database directly, because this would be a small security hole since the APPs would need have the database authentication data.
On the basis of APP, it makes an HTTP request for a page that returns the data in a structured way, such as Json or XML.
I searched for several images, but I think this one sums up better:
SeeClientwherecomputers,mobilephones,tabletsandother"station" (or servers, even other websites can request a webservice), this means that webservice caters to several locations. Web service would be the translation, that is to say that it serves to clients data via Web or outside the APP, the applications only request this data or send new data and sometimes it keeps a local copy by chance is offline or optimized. >
The webservice can be written in several ways totally independent of IDE as it said before, of course we use the IDEs to facilitate, it follows some examples of technology to use in the webservice + framework to facilitate the development:
-
If your server is PHP:
-
If you use .NET
-
Python:
In this case, the connection to the database will be the responsibility of server-side , in this case PHP, ASP.NET or Python (using framework or not).
Application
If the app is for Android you can use ADT or Eclipse to develop a webservice, you should make an HTTP request (android is usually java, source for example
Getting Data (GET)
String url = "http://[webservice].com";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
System.out.println("Código de resposta: " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
//Pega a resposta
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//Mostra a resposta no console
System.out.println(response.toString());
Sending Data (POST)
String url = "http://[webservice].com/create";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
//envia via POST
con.setRequestMethod("POST");
//Dados POST
String urlParameters = "arg2=foo&arg2=baz";
//Cria o POST
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("Código de resposta: " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//Mostra a resposta no console
System.out.println(response.toString());