Powered By Blogger

05 April, 2007

How to make Web Service with Axis 1.4 + Tomcat

I searched and searched and searched and when at last I couldn't find a good tutorial for this topic...I decided to read the manual and try some bit of fun myself making web services with Axis.
and I was thrilled to see that it was actually pretty simple so...I am gonna put it down here to be inscribed on the web world for posterity (atleast till the blogger.com server doesnt crash or something! :))

Anyways...
(Hopefully the setup is done...with Apache Axis and Tomcat)

Step 1: Make the simple server side program .java file.
It shd have the method that the client will call.

Lets say for example:


public class MyServerClass{

String MyServerMethod(String a){

System.out.println("Request Recieved");
return a+" ,this is what the client sent";

}
}


Now next step would be to compile it; a simple ' javac MyServerClass.java'.
The .class file that is generated...just put it in the Apache Tomcat - > webapps -> Axis ->web-inf->classes folder.


Impt to note: If you have put the class into a package then make sure u make the package in the classes folder before putting the .class file in it.

example:
package abc.cde.efg
public class MyServerClass{ ....

Then put the MyServerClass.class file that is generated on compilation into the
Apache Tomcat - > webapps -> Axis ->web-inf->classes ->abc->cde->efg folder. Make the 3 folders and then put the .class into the efg folder.

Step 1.5 : This is just a check
Hope the library of the Axis -> web-inf has the axis.jar etc jar files in it already!
If not best to goto axishomepage
and download the needed jars.

Step 2: Next thing to be done...
Deploying the web service on the Apache Tomcat Web Server.
We need to write the .wsdd file for this. The Web Service Deployment Descriptor is written in xml format. Its pretty easy.... you could have a look at the wsdd in this blog found it pretty good!

The things you need to modify in your wsdd would be
the service name
class Name

write it directly into a file called "deploy.wsdd"
Impt: If you have put ur class into a package make sure your
MyServerClass is changed to abc.cde.efg.MyServerClass in the className.

Now...the next thing to do is...
STARTUP the TOMCAT server!

make a .bat file in notepad and put in the following
java -cp c:\axis\lib\axis.jar;c:\axis\lib\saaj.jar;c:\axis\lib\xerces.jar;c:\axis\lib\activation.jar;c:\axis\lib\axis-ant.jar;c:\axis\lib\commons-discovery-0.2.jar;c:\axis\lib\commons-logging-1.0.4.jar;c:\axis\lib\jaxrpc.jar;c:\axis\lib\xercesImpl.jar;c:\axis\lib\xml-apis.jar;c:\axis\lib\wsdl4j-1.5.1.jar;c:\axis\lib\mailapi_1_3_1.jar;c:\axis\lib\javax.jms.jar;c:\axis\lib\log4j-1.2.8.jar org.apache.axis.client.AdminClient -lhttp://localhost/axis/services/AdminService deploy.wsdd

Dont change the other part just edit the name of your file if you have saved it different from deploy.wsdd.

Make sure you are in the folder where deploy.wsdd is present when you run the .bat file.

Step3:
Ok...now that this is done...

goto...http://localhost/axis/
and click on the List ...it will show you all the deployed web services!!

You can now make a simple client for this web service ...

Congrats! you now have an up and running webservice. *hurray!*

12 March, 2007

Spring with Jdbc

Yay! I finally managed the unmanageable!
Got Spring framework working with JDBC DAO, had to install MyEclipse though. That IDE is pretty cool. (Netbeans should seriously get a plugin for spring,makes life easier.)

Secret is dont try using MS SQL for this activity unless you wanna use the normal JDBC ODBC driver (not sure if it works though)...they have a MS SQL jdbc driver available online...you may want to check it out. But for novices like me, please use postgreSQL as ur database of choice. Its good easy to use and the GUI is cool!And the driver is available online too and u simply got to add the driver to MyEclipse. ("Help" is ur angel!)

a link that will be useful for the beginner:
http://www.laliluna.de/eclipse-spring-jdbc-tutorial-en.html

My next step in this battle is to get Hibernate working..
Gotta get to reading tutorials reg. those too...damn!
*for now , yay*

07 March, 2007

Meaning of Work ??

Phew! and well, once done with the tech stuff the mind can relax and engage in higher activities like figuring out if God exists.... or well.... in my case, do the highest form of mind exercise - bring myself to doing school work! The horror!

Having been bogged down with internship and school work at the same time I sometimes wonder if other people also have such experiences of horror and woe [or is it that their lives are easy with no work , no school just parties....hmmm... the luck of the idiots!]

Oft I have wondered if taking up such a tech major in Uni has signed me for a lifetime deal of a 9 to 5 job with no life apart from computers and no topics to talk about than tech...Oh Gosh! hurts to even think of it...

But thinking abt the most fundamental thing in the whole discussion....

why do I want a job? Why do I want to work?
Apart from obvious economic reasons.. why do I wanna work? or why does anyone in this whole wide world want to work?

If an individual won a lottery of a 100 billion dollars will he/she stop working for life?
Put urself in the shoes of the person and think...will you?

Hmm...this post will be continued...gotta think of some good answers *hmmm*

After my philantrophy

I always wanted to do my bit for the world hence I gave away precious knowledge accumulated after hours of searches (read Apache Tom... post). Anyways, my friend PJ feels technical blogs dont bring out your personality fully, he is right! I have great respect for the guy...he is quite a thinker (no jokes here...)
So we discussed and came up with a lot of topics...they included a lot of how-to s based on experience...
how to destroy ur sleep cycle
how to never lose/gain weight
(Depending on which one u wanna do.. and then put a never in front of it)

how to skip gym with valid self-excuses
(self-excuses : justifications given to oneself,
for the ones who dint get it!)
how to submit assignments on time when u have just 2 hours to go and u just started!!
but yeah ... after all that brooding I have decided to comment on the happening around the world and mix it with my own tales of woe / happiness but I hope to put in some tech stuff if I can ever find anything irksome enough to include... which I am sure I will...
*smiles*


06 March, 2007

ApacheTomcat + Spring with netbeans on the side

One of the most unnerving experiences (apart from 2 earthquake tremors in one day, yeah there was an aftershock later) would be installing Apache Tomcat and making it work with netbeans and not to forget Spring Framework....
Lemme start off with my tale of woe and then later go onto the part where I let out the secret of how to get it working finally ...(yes, may google be blessed! after a day's worth of googling I found all the missing links and got the setup working)...

Tales of woe are pretty useful especially in the technological field ( but I know no one is gonna particularly find it useful to hear me grumble with intricate details of my every hour on that fateful day!!)
But I can include a few lines of what - not - to - do s....

If you are looking for Apache Tomcat its best to go in for the preconfigured zip file
http://www.coreservlets.com/Apache-Tomcat-Tutorial
/Preconfigured-Tomcat-Version.html

cuz the installation steps require a LOT of changes otherwise and its best NOT to try doing the configurations urself unless of c you are a masochist, then by all means please go ahead!

The tricky part is learning to set the PATH and CLASSPATH etc which is necessary and you could go ahead using the cmd (command prompt) for it OR use Control Panels - >System ->Advanced Tab ->Environment Variables.

After that of course try running your tomcat by clicking on "startup.bat" in the bin folder and goto ur nearest web browser and type http://localhost:8080/ (depends on ur port number, I set it to 8080)
If all is well you would see the apache page, and then you can give ur first sigh of relief. :)

Ok, the problem I faced was basically due to trying to configure things myself. Of course this is as I mentioned before - pure torture...

If ur using netbeans then simply unzipping spring framework and adding it to your Library will do the trick --- now ur ready my friend , try making some programs...of c its gonna be hard trying to figure out how many config files u gotta write...but I am sure u can google it. I am gonna start on that now *hope still prevails*