Wednesday, July 20, 2011

Developing web services using Apache Axis2

I am going to present to all folks who are eager to develop web services using Apache Axis2. I am assuming that you guys have fair idea about what web service is, SOAP, structure of a valid WSDL, and all the basics about web services.

What I am about to tell you is if you have a valid WSDL document(xml) then it's quite easy to develop a web service out of it in simple steps. This is called the top down approach. Apache Axis2 distribution provides set commands that generates Java code when WSDL is given as input. The generated code is just a skeleton of the web service wherein you have fill it with your business logic.

Requirements:
  • Eclipse IDE 3.4 or above
  • Apache Axis2 (stand alone) 1.4 or above: Download releases
  • A WSDL ( I am using CalcWSDLFile.wsdl)
In the axis distribution folder: ${AXIS2_HOME}/bin, you will find two script files: WSDL2Java.bat & Java2wsdl.bat. I will be using wsdl2Java.bat for since I am working on Windows and also because it's a top down approach. If you are working under Linux, there will be respective .sh files accordingly. 
My WSDL file: CalcWSDLFile.wsdl

This script (wsdl2java.bat) uses few options to generate code accordingly. Now, we are all set. Along with this, these steps will allow you to setup your development environment correctly.

1. Create a folder with name CalculatorWS. I have created it under C:\Amit\webservice\. This will be your workspace (project) folder in Eclipse. 

2. To generate server side code: Execute the below line:
wsdl2java.bat  -ss -g -u -sd -ssi -d adb -uri  C:\Amit\webservice\CalculatorWS\wsdl\CalcWSDLFile.wsdl  -o C:\Amit\webservice\CalculatorWS
-o: The path where the code is generated. The absolute path of folder: CalculatorWS
-uri: The path of of your WDSL file
The command should execute without throwing any error. To know more about rest of the script options mentioned above, have a look at the reference

3. Copy the lib folder under ${AXIS2_HOME} to C:\Amit\webservice\CalculatorWS\
i.e. the absolute path of lib will look like: C:\Amit\webservice\CalculatorWS\lib

4. Open Eclipse. File -> New -> Java Project. Now, provide project name. In the Contents frame, select “Create project from existing source” and provide the path of folder: C:\Amit\webservice\CalculatorWSClick Finish. Your Eclipse work space is now setup successfully.
Look of my workspace: CalculatorWS

5. Now, next thing is to fill the generated with business logic. As highlighted in the screenshot, there will be a source file with the name: {service-name}Skeleton.java. {service-name} is got from the WSDL. This is the file where you come in, process the request, do some logic and reply with a response. 

Deployment
Once you are done with your development, it's time for deployment.

1. Create a folder named CalculatorWS under ${AXIS2_HOME}\repository\services. Then create a folder with name under META-INF under ${AXIS2_HOME}\repository\services\CalculatorWS

2. Copy all the files under C:\Amit\webservice\CalculatorWS\resources to ${AXIS2_HOME}\repository\services\CalculatorWS\META-INF. This folder contains XSDs, WSDLs and other web service related XMLs.

3. Copy all the compiled class files along with packages from work space folder: C:\Amit\webservice\CalculatorWS\bin to ${AXIS2_HOME}\repository\services\CalculatorWS.

4. Your web service is now successfully deployed. Open command prompt, goto ${AXIS2_HOME}\bin

5. Run the command axis2server.bat. You will see that your service is being deployed successfully. From the browser, navigate to URL: http://{your-host-name}:{axis2-server-port-number}/axis2/services/. For example, in my case: http://localhost:8090/axis2/services/
Web service getting deployed successfully
A list of deployed web services is displayed. Click the hyper link of your web service, the WSDL is displayed. Look for the tag soap:address. The value of the attribute location is the URL for the clients to connect to this web service. SOAPUI is a good client to test your web service.

I hope people will find this post useful.

Friday, July 15, 2011

First Impression is NOT always the Last Impression

In the recent years, I am not believing with the quote - first impression is the last impression. Its only about how I present myself to the people around me. I believe this saying rather discourages or demoralizes people from proving themselves.

Let me substantiate my belief with live instances. I am a less talkative guy. But that doesn't mean that I don't I talk at all. By this characteristic, people judge me as an introvert. I remember one of my managers at workplace saying this when I first joined the company. So, my work in the company was scrutinized for first few months. They thought I wasn't working well. This was their first impression. I knew it was uncomfortable to work under such conditions, but I suppressed this feeling. I said to myself "I am gonna show them who I really am!" As days went by, I worked stretching myself a little longer but made very sure I work my way. When the product delivery was made successfully, everyone was happy. Moreover, my potential and my work was highly recognized. This is the second impression. I guess the first impression is vanished now. My managers are happy with me as long as I get the work done.


Similar thing happened within my family. Even though I was a hard worker, my effort did not get reflected in my engineering result sheets. My parents underestimated me very much. They dreamed of me working in a reputed company. But what they were practically watching was that I was going nowhere. Finally, with God's grace, my effort became fruitful when I started my started my professional career three and half years ago in August 2007. With some  struggles & troubles during beginning stages of my profession, I am sure they are happy to see what I am now. Again, the second impression is what really counts.

If you have the potential then you don't really have to worry. It takes some time to show itself. But, don't let yourself down. Hard work really pays off in a grand fashion. Don't even make an attempt to impress anyone. Because you are only one of your kind. Be happy the way you are. Never look back. Always look ahead in search of learning new things, that you think, helps you prosper your life and gain the right potential. And as I move on, I don't rely on first impression of a person. Instead I study that person for sometime because I know it might change with time. Some quotes remain just as quotes.

Thursday, July 7, 2011

Doyle and Christie

I have been reading stories of Hercule Poirot by Agata Christie for a month now. The volume has 51 stories. I am done with 31. There are few observations to make. In most of her Hercule Poirot stories, Captain Hastings is always an admirer of women. Here is one of descriptions:
"In another minute one of the most charming girls I have ever seen was ushered into the room.  She was perhaps about five-and-twenty, with big brown eyes and a perfect figure. She was well dressed and perfectly composed in manner." - from the story: The Million Dollar Bond Robbery
 And another one:
"'Mrs. Robinson did not seem to notice anything amiss. Very curious. is it not? Did she impress you as being a truthful woman, Hastings?', Poirot remarked.
'She was a delightful creature!', I said
'That's evident! since she renders you incapable of replying to my questions. Describe her to me then'
'Well, she is tall and fair, her hair's really beautiful shade of auburn - blue eyes and a very nice complexion and - well, that's all, I think', I concluded lamely" - from the story: The Adventure of the Cheap Flat
In Sir A. Conan Doyle's Sherlock Holmes stories, Holmes and Watson admire women in rather different ways. Here is a famous example:
"To Sherlock Holmes, she was always the woman..... In his eyes she eclipses and predominates the whole of her sex. It was not that he felt any emotion akin to love for Irene Adler. All emotions, and that one particularly, were abhorrent to his cold, precise but admirably balanced mind..... They were admirable things for the observer - excellent for drawing the veil from men's motives and actions. But for the trained reasoner to admit such intrusions into his own delicate and finely adjusted temperament was to introduce a distracting factor which might throw a doubt upon all his mental results..... And yet there was but one woman to him, and that woman was the late Irene Adler, of dubious and questionable memory" - from the story: A Scandal in Bohemia
Do you notice the difference between the two great writers? Women's appearances are better described  in Poirot's stories as compared to that of Holmes's stories. And, you will also find women will be in leading roles in most of Christie's tales, but its quite the opposite in Doyle's stories; men are in leading roles!

Talking about the stories, Doyle more convincingly describes the science of deductions and motives as compared to Christie. When you end up reading stories of Hercule Poirot, they are good, but you are forced to believe the facts, although at the back of your mind, you wonder - something is missing/wrong here! But, when you read stories of Sherlock Holmes, you feel you should remember these stories for the entire lifetime. The plots are complex enough to twist your mind and the way mysteries are solved is simply superb. Christie introduces too many characters which I find difficult to keep track of them and in some of her novels, the plot circles round the same thing and does not proceed further. In the meantime, I wonder what the plot was! I am sorry to all Agatha Christie lovers, but this is what I have felt. The bottom line is: if you want to be a flirt, read Christie's stories, otherwise read Doyle's stories if it is intelligence that absorbs you. I won't forget to mention few classics like, A Scandal in Bohemia, The Adventure of Dancing Men, The Man with a Twisted Lip, The Adventure of Second Stain, The Speckled Band and The Hound Of Baskervilles, which I consider are masterpieces by Doyle.

Let me remind you Doyle & Christie are not contemporaries. I believe the originality of a person or the power of thinking independently dies when you try to copy the work which is already done in a more beautiful fashion. All Christie did was she created a new Sherlock Holmes by a different name: Hercule Poirot. You can also find characters of Dr Watson, Inspector Lestrade and Mrs. Hudson mapped similarly in Poirot's stories. In Christie's autobiography, she admits these facts saying that when she was creating Poirot, she also wanted all the characters which were similar to those in Sherlock Holmes stories.

I don't know whether I am going to finish reading this volume because I am really bored with the stories. I am not finding it interesting anymore. Its going nowhere. So, which one's next?

Saturday, June 25, 2011

Ageless Mind

When I met my schoolmates during third week of June it was beginning of monsoon in 2011. This meeting was after 10 long years. We had been longing for this moment since years. When all of them shot their first look on each one of us, everyone was quite observant on each other's features. Most of them said to each other "Look at you! What has become of you! My God! You have changed completely! I couldn't recognize at first! How could you change so much?"

Of course there were few of my friends, including me ;), who didn't seem to have changed considerably by looks. So, despite some trivial changes, some guys said, "You haven't changed a bit! You are still the same as I saw you 10 years ago back in school!" But no one can deny the fact that people can't change at all. It is just the face that remains as the identity of a person.

Look at the other side of this subject. You have brothers and sisters. You grow along with them. Even after some years, when people say that your brother or sister has changed, you don't agree at once! Because you have seen them grow all along with you. Their images get updated everyday in your mind as you have been seeing them till date since your birth. So, you hardly notice any change in them. You will realize the truth only when you look back to see those old family albums or old family videos you made during family gatherings, parties, etc.

Before I met my schoolmates, my mind had images of them which were 10 years old. And now, suddenly when I saw them, my mind was reluctant to accept current images of my friends. It accepted only couple of minutes later during which it analysed their new or updated features - his nose is elongated, her eyes are geared with specs, she was apparently taller, but she is now short, he has put on weight, he also has a double chin now, etc and updates its photo store.

All humans have ageless minds. If you update your mind regularly, its well and good. You say that everything is going fine and you are moving on nicely. But, when you meet your friends or anyone who was close to you, after a long time, you notice that there is something out of the ordinary, because you want to see them the same way as they were long ago! Yes, it sounds very funny but I think it is the bare fact. Just imagine when you don't meet your old friends at all or when you don't think about them, there will be some kind of twitching in your mind saying "Nothing much or major has changed." Mind is a constant learner. It always wants put new things into itself. I think it is very young to learn many things; and how does it learn? By means of our five senses and by thought processes involved in experiences of our day-to-day lives!

I understand that I should have described how happy I was when I met my friends, the nostalgic moments cherished; funny instances, quarrels, punishments for behaving badly or for not doing homework, gossip about teachers, etc. All these priceless moments are to be experienced at that very moment and are to be remembered forever. If I start writing, I suppose there will never be an end if I elaborate these memorable things. Moreover, we spent the entire day enjoying ourselves. So, it does not qualify to be a blog post which describes everything about that very special day.

Dedicated to all my schoolmates
Class of  2001
MR Sakhare English Medium School, Hubli

Saturday, June 18, 2011

Switching Languages

Well, it's not the first time to happen to me, but many times. I feel it is very strange. Sometimes, I also feel that people are strange. I don't really have an answer for this. But, I am never concerned about it. I just accept it as a joke on my part :)

First time it happened to me in my college during my first year of engineering. It was a mechanical lab session where all the students where are asked to solder some pieces metal together in order to form a required shape. I went to the lab assistant asking for more pieces of lead. You know, we had to melt those pieces, using a soldering gun, on the joints. I said, "Sir, box khaali aagide, Lead pieces illa. Nanage innu swalpa beku." in Kannada (The box is empty. There are no Lead pieces. I need some more). He stared at me with a great surprise. His eyes were bigger than they were. Now, I was surprised to see him taken aback wondering what made him to be surprised. I knew something went wrong. But what was it? He cleared his throat and finally he said "Hmm, tum  ek-do minute ke liye wait karo, mein leke aatha hoon." in Hindi (Wait for couple of minutes, I'll get them). This time, I was surprised to see him reply in a different language. I was about to say "OK sir, thank you" in Hindi when I started stammering because my tongue finds its difficult to switch languages quickly. I managed to say "Ada...ba...than...ka..da..", then tried very hard to stop talking and  managed to mute my voice. Later, I kept wondering - I think he understands Kannada, but he is unable to speak it or did he think I didn't know Kannada? What makes him think so? After a short while, I thought latter was true when he was talking to his colleagues in Kannada.

Later today a similar thing happened when I was waiting at a bus stop. It was quite late. I was doubtful whether I could catch a bus this time around. I asked a man who was standing close to me, "Sanjay Nagar ge hoguva bus sigabahude, eega?" in Kannada (Can I get a bus which goes to Sanjay Nagar by any chance now?). His quick reply was in English, "I am waiting for the same bus. We will be lucky if we get one. Time is already up. We might have missed it, but I am still waiting for it hoping that I did not miss it!". I nodded approvingly. This time I made sure my mouth is shut not to speak out anything! I was little surprised. It reminded of the situation which happened during my engineering. Again, after a while, I saw that man talking to a fellow passenger in Kannada.

These are the instances I can remember now. There are many more if I recall. There must be something about me that makes some people decide that I am a non Kannadiga. Am I so different by looks to some people that they fail to recognize me as a native Kannadiga? What's on me? I don't know. I just let it go. As long as it's not bothering me, I enjoy these moments and laugh about it. On a final note, beat this tongue twister:
How much wood would a woodchuck chuck if a woodchuck could chuck wood? He would chuck, he would, as much as he could, and chuck as much as a woodchuck would if a woodchuck could chuck wood.