Though both SOAP and RESTful web services allows a client to query server for some information, but the way they are implemented and used is quite different. Main difference between SOAP and REST is that former provides an standard of communication between client, server and other parties and has restricted set of rules and format, while REST leverages ubiquity of HTTP protocol, in both client and servers, to allow them to communicate with each other regardless of their implementation. In short, getting data from a RESTful web service requires less headache then getting data from a SOAP web service. Since everybody is familiar with HTTP requests like GET or POST, its easy to understand and correlated how RESTful webservice are working and which URL of REST web service provides what kind of information. In SOAP, you need to understand lengthy WSDL document to find out right methods and right way to call them.
Monday, August 31, 2015
Saturday, August 29, 2015
Unsupported major.minor version 51.0 error comes when you run a class file created using Java 1.7 (major version 51.0) into a lower JRE version e.g. JRE 6, 5 or 4. There are two ways to solve this problem, first make sure you run your Java program in same or higher version of JRE, on which it has compiled, and second use cross compilation option to create a class file compatible to a lower JRE. You can use javac -target option to create a class file for all JRE up-to the JDK version you are using for compilation. For example, if you are compiling your Java source file into JDK 1.7 then you can create class files to run on JDK 1.1, 1.2, 1.3, 1.4 , 1.5 and 1.6 version, but you cannot create class files compatible with Java 1.8. When you compile a Java source file, it creates a class file and add the class file version into it. In order to run that class file, your JRE must understand that version. When JRE or JVM which is running the class doesn't able to understand the class file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is name of your class which has incompatible version.
Wednesday, August 26, 2015
Factorial of numbers greater than or equal to 13 cannot be found using primitive int data type as shown in our earlier factorial solution due to overflow. These factorials are too large to fit in an int variable, whose maximum value is just 2147483647 (2^31 -1). Even if we use the long data type, factorials greater than or equal to 21 will generate an overflow. To find factorial of anything above 21, you need to use the BigInteger class from java.math package. As name suggests, BigInteger class is designed to hold really large integer value, something which is even bigger than maximum value of long primitive e.g. 2^63 -1 or 9223372036854775807L. You also need to change the way we calculate factorial for smaller number. You can not use recursion to calculate factorial of a larger number instead we need to use for loop for that.