Web Services – Chapter 2

http://knowledge-cess.com/web-services-chapter-2-2/

RESTFul Web Services – A First Step

Before starting with RESTFul web services , one must be knowing the basics of web services, We have studied basics of web services in our previous chapter, Once you learn basics, it will be great to go ahead.

As we discussed in previous chapter Web services plays a major role in future of web. We will try to learn how the things will be developed, we will have a hands on with development of web services using java. Before starting with web service development we will like to give step-by-step guide for java setup.

We need java sdk installed, tomcat server installed and eclipse as an IDE for development. Web services can be developed with PHP, C# .net , Ruby on Rails. Since our team is comfortable with java, we would like to write further chapters targeting java for the same.

Set-up for Mac Users
Install Java sdk
1> Download jdk 7 from the link

2> Double click on .dmg file , which opens a window and double click on package file as shown in the fig below.

jdk dmg img

3> Click continue in the installation window

4> Enter user name and password of your system

Install tomcat
1> Download tomcat from the link
(Download the zipped file – zip (pgp, md5) )

2> Unarchive the tomcat folder from your download folder.

3> Open the terminal and execute the following commands

These commands are used just to move the tomcat folder into /user/local folder.

sudo mkdir -p /usr/local

sudo mv ~//apache-tomcat-7.0.47 /usr/local

(Usually it will be sudo mv ~/Downloads/apache-tomcat-7.0.47 /usr/local)

4> Create symbolic link for the tomcat – this helps to keep tomcat updated when we get latest tomcat updates.
First create tomcat folder
sudo rm -f /Library/Tomcat

Create symbolic link of tomcat
sudo ln -s /usr/local/apache-tomcat-7.0.47 /Library/Tomcat

5> To make tomcat executable, the ownership of the folder must be changed
sudo chown -R <your_username> /Library/Tomcat

6> To start and stop tomcat we need to run the scripts, to set the execute permission to scripts run the below command

The installation of tomcat is done!
Check whether tomcat starts smoothly or not by starting tomcat with the script
Screen Shot 2014-06-04 at 8.50.01 pm
knowledgecess:~ cess$ /Library/Tomcat/bin/startup.sh

Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar

knowledgecess:~ cess$ /Library/Tomcat/bin/shutdown.sh
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH:
/Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
knowledgecess:~ cess$

In our next chapter let us try to create a sample on web services in Java.