Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
What is WebService?
Web Services is the mechanism or the medium of communication through which two
applications / machines will exchange the data irrespective of their underline
architecture and the technology.
In the modern era of technology if you want to build a software application you don't
need to build each and everything from scratch. There are lots of readymade
services available which you can plug into your application and you can start
providing those services in your application.
For example you want to display weather forecast information you don't need to
collect, process and render the data in your application. You can buy the services
from the people who already well-established in processing and publishing such kind
of data.
Web Services can be implemented in different ways, but the following two are the
popular implementations approaches.
SOAP uses the XML format to send and receive the request and hence the data
is platform independent data. SOAP messages are exchanged between the provider
applications and receiving application within the SOAP envelops.
As SOAP uses the simple http transport protocol, its messages are not got blocked
by the firewalls.
http://www.webservicex.com/globalweather.asmx?WSDL
REST
There are various code that REST use to determine whether user has access to API
or not like code 200 or 201 indicates successful interaction with response body while
400 indicates a bad request or the request URI does not match the APIs in the
system. All API request parameters and method parameters can be sent via
either POST or GET variables.
Rest API supports both XML and JSON format. It is usually preferred for Mobile and
web apps as it makes app work faster and smoother
/* if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}*/
//Post request
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
https://www.guru99.com/webservice-testing-beginner-guide.html
https://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/
https://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/
https://dzone.com/articles/restful-web-services-java
http://www.groupkt.com/post/f2129b88/free-restful-web-services-to-consume-and-test.htm
http://www.groupkt.com/post/c9b0ccb9/country-and-other-related-rest-webservices.htm
https://www.javatpoint.com/web-services-tutorial
https://stackoverflow.com/questions/10926353/how-to-read-json-file-into-java-with-simple-json-library
http://www.differencebetween.net/technology/internet/difference-between-api-and-web-service/