Thursday, July 2, 2015

Web Service with Axis 2 in eclipse

Axis2 Web Service using Eclipse - Java Tutorial Blog

Axis2 Web Service using Eclipse

There are different web service implementation engines available for Java. Axis2 from Apache is the popular web service stack. In this hello world tutorial, we will use Axis2 for implementing a simple web service using Eclipse wizards. Eclipse does not come with pre-configure Axis2 setup. So the key to creating a web service using Eclipse for Axis2 is setting up the Eclipse.

Axis2 Eclipse

Step 0: Eclipse Preparation for Web Service with Axis2

See when we are lazy and want all the job to be done by an IDE, we should have the right setup and configuration. To create a RESTful webservice with Axis 2 using Eclipse wizard ensure the following.

  • Use Eclipse Java EE IDE for Web Developers.
  • Have the latest Dynamic Web Module updated. It is better to use 2.5 of dynamic web module version. Simple and easy way is to have a latest IDE download as it will come bundled with latest modules.
  • Download Axis2 binary from Apache Axis website download page, unzip it and configure that foder in Preferences -> web service Axis2 runtime (refer image below)

Axis2RuntimeConfig

If you are in a hurry, just download Axis2 Web Service and Client project and execute it. You should add Axis2 jars in lib folder.

Step 1: Create Dynamic Web Project

We all know how to create a dynamic web project for Java in Eclipse as it is what we do daily in our office.

NewWebProject

To create a web service using Axis2 we should add a step. Just do not go with the default runtime (server) configuration. We need to add Axis2 Web Services in Project Facets. Click Modify button for server runtime configuration while creating the dynamic web project and select the Axis2 Web Services Project Facet.

Axis2FacetConfig

Then click next, next, next … done. A brand new Java dynamic web project is created with runtime support for Axis2 web services.

Step 2: Create Web Service Java Class – Bottom up style

It is going to be simpler than expected. We will use the bottom up style for web service creation. First we will create the Java class and generate the WSDL out of it. Create a new Java class with a method that will serve as the heart of web service.

package com.javapapers.webservice;

public class Axis2HelloWorld {
	public String helloWorld() {
		return "Hello World";
	}
}

Step 3: Create Axis2 Web Service and Client using Eclipse Wizard

NewAxis2WebService

Just the wizard job is remaining. Now use the create new web service wizard. Choose the service class that was created in the previous step and click next to finish. If you choose the web service client generation, then we will get a separate web application generated by Eclipse. Thats it, we have created a hello world Axis2 web service and client using Eclipse.

Axis2WebServiceResponse

Here I found this source code from javapapers.com Download Axis2 Web Service and Client project. You should add Axis2 jars in lib folder.

This Web Service tutorial was added on 16/12/2012.

Additional information

With eclipse juno I installed axis2 1.6.2.0. 
Downloaded files

http://axis.apache.org/axis2/java/core/download.cgi

Binary and war distributions.

Binary file extracted and the jar file added to eclipse/droping folder straight away.
War file extracted to a target folder and added the path the eclipse window-> preferences-> web service -> axis preferences

!!! Error - I got message axis2 run time was added successfully. But actually it didn't work in the later step while creating web service.

Solution - I added the path  by using browse again without pasting. PROBLEM SOLVED. !

This was the helpful forum....
http://www.eclipse.org/forums/index.php/t/160369/

 Created example using this website.
http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/bu_tutorial.html

My first angular app

As Hello word program there are few basic things to know in angular.

  • What is angular
  • How to use
  • When to use
  • Basic structure or tags

Misko Hevery, of Google, is the founding co-author of AngularJS. There's couple of things in Angular make it special. First of all, we have dependency injection, which is very unique. Nobody else has that. But I think that the thing that really hits it home for people is that we have this idea of a directive. Rather than writing everything inside of JavaScript and then having a bunch of templates to generate the UI, you write a lot of it in HTML and HTML drives the assembly of the application. It's kind of the reverse thing. It's very unique. No other Jframework had it till Angular brought it. Want to know more..http://www.infoworld.com/article/2612801/javascript/what-s-so-special-about-google-s-angularjs.html

How to use angular in your application? Just add ""to the html file.Else download Angular.js or Angular.min.js add the path with "script" as similar to the above. But make sure you do it before you call any Angular directive in the code.

When to use angular? Angular enable two way binding. Fast scripting. Support for lot of functions you want to add in to the website.

Let's see how it works. It starts with adding "" directive to the html structure elements as "", "div" etc..It defines the angular application. inside that we can add all the other directives. Remember !!! Per page there can be only one "ng-app" directive, also if you use google api to add Angular then you will have to use "data-ng-app" directive.

Basic directives need to know in Angular are "ng-controller" defines the controller function to handle the DOM."ng-bind" It's really easy way of binding dynamic data.

We are good to go now. The first angular application.

<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script> </head> <body> <div ng-app="HelloWorldApp" ng-controller="HelloWorldController"> <h1> Hello <text ng-bind="who"> </h1> </div> <script> var HWApp = angular.module('HelloWorldApp', []); HWApp.controller( 'HelloWorldController', ['$scope', function ($greet) { $greet.who = 'World!'; } ] ); </script> </body> </html

Hello

Wednesday, May 20, 2015

What? you want to install skype on Fedora 64-bit?

As most tech blogs suggest I could get through it. But the installation might not be same to everyone. Basically few steps to follow.

Step 1 : Install dependencies

Log in to root user
su -
## OR ##
sudo -i
 


yum install alsa-lib.i686 fontconfig.i686 freetype.i686 glib2.i686 libSM.i686 libXScrnSaver.i686

and set of commands below

yum install alsa-lib.i686 fontconfig.i686 freetype.i686 \
glib2.i686 libSM.i686 libXScrnSaver.i686 libXi.i686 \
libXrandr.i686 libXrender.i686 libXv.i686 libstdc++.i686 \
pulseaudio-libs.i686 qt.i686 qt-x11.i686 zlib.i686 qtwebkit.i686
 
 
 


Download and extract skype

cd /tmp
 
## Skype 4.3 Dynamic for Fedora/CentOS/RHEL/SL ##
wget --trust-server-names http://www.skype.com/go/getskype-linux-dynamic



mkdir /opt/skype
 
## Extract Skype 4.3 ##
tar xvf skype-4.3* -C /opt/skype --strip-components=1


Create Launcher

ln -s /opt/skype/skype.desktop /usr/share/applications/skype.desktop
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/icons/skype.png
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/pixmaps/skype.png
 
touch /usr/bin/skype
chmod 755 /usr/bin/skype


Open skype file in bin and add the edit to add the below scripts
Open
vi /usr/bin/skype

Add:

#!/bin/sh
export SKYPE_HOME="/opt/skype"
$SKYPE_HOME/skype --resources=$SKYPE_HOME $*

and finally hope we got there

[root@fedora ~]$ skype

Errors :(

If this is not working and gives errors like below.


[root@fedora ~]$ skype 

skype: error while loading shared libraries: libXss.so.1: cannot open shared 

object file: No such file or directory



Simply search the trouble making dependency like below


[root@fedora ~]$ yum whatprovides libXss.so.1 

libXScrnSaver-1.2.0-1.fc12.i686 : X.Org X11 libXss runtime library 
Repo : fedora 
Matched from: 
Other : libXss.so.1



It shows you where to find the library.

then install the missing part

yum install libXScrnSaver.i686

Then again when trying to install skype if you get
[root@fedora ~]$ skype 
skype: error while loading shared libraries: libQtDBus.so.4: cannot open shared object file: No such file or directory

Type below

[retarp@misterlappy ~]$ yum whatprovides libQtDBus.so.4 
Loaded plugins: langpacks, presto, refresh-packagekit 
Adding en_US to language list 
1:qt-4.7.0-3.fc14.i686 : Qt toolkit 
Repo : fedora 
Matched from: 
Other : libQtDBus.so.4 


1:qt-4.7.1-17.fc14.i686 : Qt toolkit 
Repo : updates 
Matched from: 
Other : libQtDBus.so.4

and install the library as given in the red block.

yum install qt.i686

DO it for all the missing dependencies. It will be alright soon. I found it through log of references. The below will give you more insights if you want.

http://www.if-not-true-then-false.com/2012/install-skype-on-fedora-centos-red-hat-rhel-scientific-linux-sl/

http://emildavis.info/FedoraSkype.html