JDK Version history - Best Features

JDK Version history - Best Features

In this post I'll not go deep into each feature but keep it as a chit-sheet for interview preparation on different JDK best features in different versions. 

JDK 7 - new and best features
1. Diamond operator / Type interface >>
2. String is now allowed in Switch
3.Automatic resource management - try-with-resources statement
4.Underscore in Numeric literals _
5. Improved exception handling - Catching Multiple Exception Type in Single Catch Block
6. New file system API (NIO 2.0)
7. Binary Literals with prefix "0b"
8. Fork and Join
JDK 8 - new and best features
1. Lambda Expressions, a new language feature, has been introduced in this release. They enable you to treat functionality as a method argument, or code as data. Lambda expressions let you express instances of single-method interfaces (referred to as functional interfaces) more compactly.
2.Collections :  Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements.

Reference : [1] [2] [3]

Read more


Creating Web-Service Client for online webservices using AXIS2


Creating WS Client for on-line Web-services...

First we should know who is providing on-line web-services(WS).
http://www.webservicex.net is one such site where we can find different on-line web-services like Stock Quote, IP Locator etc.

We can see WSDL file for each WS in the above site and using this WSDL we need to generate our client and to query the WS .
We can send request to the on-line Web-service and in turn we get response for the request from WS .
So For example if we have generated Stock Quote WS client code , in request we send a symbol (for EX: IBM) to request it's recent stock quote value.
So in response we should get it's latest value and other stuff.

Before we generate WS Client code for provided WSDL in Stock quote from http://www.webservicex.net  .
Let's see how it works

SOAP UI is one of the easiest way to check this out.
Download SOAP UI ZIP and launch the SOAP UI . http://sourceforge.net/projects/soapui/files/soapui/5.0.0/SoapUI-5.0.0-windows-bin.zip/download
After extracting you can run file : soapui.bat from it's extracted location Webservices_Stuff\SoapUI-5.0.0\bin

Create a new project for example StockQuote in SOAPUI and provide WSDL path taken from http://www.webservicex.net for Stock Quote
WSDL used :
http://www.webservicex.net/stockquote.asmx?WSDL

On the left hand side in the SOAPUI new project is created with GetQuote and Request 1 etc.
If we double click the Request 1 we will see a window opened with two parts one with Request XML and other one Response XML.
There in the Request XML if set the ? symbol with IBM like one company symbol and click on run button on the top it gives us the response with
detailed information on the stock.

So now our next job is to create client code for the StockQuote in our eclipse .
So first let's download the AXIS2 project to help on this.
Download axis2-1.6.2-war.zip , from http://archive.apache.org/dist/axis/axis2/java/core/1.6.1/axis2-1.6.1-war.zip
And Create a user library to hold the required jars in path ...
Look for screenshot attached.

Now create a java project with name StockQuote and From Eclipse Run > RunConfigurations create new StockQuote run configuration.
In the main tab provide Project name as StockQuote and provide main class as
org.apache.axis2.wsdl.WSDL2Java

In the Arguments tab
under Program arguments
provide required arguments like

-o C:\Krish\MyDocs\WorkSpaces\My_Java_Workspace\StockQuote
-p com.demo.ws.stock.quote
-u
-uri http://www.webservicex.net/stockquote.asmx?WSDL


Now run this Run Configuration
Refresh the StockQuote Project from left navigation on Eclipse.
Now You should see new code file created for StockQuote Web-Service Client under Src directory.

Observe StockQuoteStub.java file.

to find out how to construct Request and Response objects
Now write your main client class ... sample file looks like below ..

Sample Main Code : 
import java.rmi.RemoteException;

import net.webservicex.www.GetQuote;
import net.webservicex.www.GetQuoteResponse;

import org.apache.axis2.AxisFault;

import com.demo.ws.stock.quote.StockQuoteStub;

public class MainClient {

 public static void main(String[] args) throws RemoteException {

  try {
   StockQuoteStub stub = new StockQuoteStub();
   GetQuote gq = new GetQuote();
   gq.setSymbol("IBM");
   GetQuoteResponse resp = stub.getQuote(gq);
   System.out.println(resp.getGetQuoteResult());
  } catch (AxisFault e) {
   e.printStackTrace();
  }

 }

}
Sample Output after running this WS : 
IBM197.024/15/2014-0.75195.99197.41195.425353177205.2B197.77-0.38%172.19 - 211.9814.94213.24International Bus

Read more

Translate

Enter your email address:

Buffs ...

Visitors


hits counter
View My StatsCheck Google Page Rank

Add to Google Reader or Homepage

Bookmark and Share

Tags


Powered by WidgetsForFree