File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Facing Problems Running My First WebService Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Facing Problems Running My First WebService" Watch "Facing Problems Running My First WebService" New topic
Author

Facing Problems Running My First WebService

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am learning WebService. I am using Axis 1.5.1, Eclipse and Tomcat 6.0.29. I am referring to the tutorial:
http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/bu_tutorial.html

After creating the host, when run the project on Tomcat, i get this error:




And my browser shows:



I read somewhere that it is a common problem with Eclipse. Is it true? Please help.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

Host means Web Service?

How are you creating Web Service?
If you are using Eclipse, you can just right click on the file, which you wanted to expose as Web Service, and say create webservice.
It asks for the options, create, deploy test etc.

If you select test, the Webservice will be deployed on the Tomcat and a web page opens with your webservice methods...

Hope that helps!


SCJP 5, SCWCD 5
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I am getting this error after i do the step 17 (on the tutorial link), when the server actually starts. I am doing the same thing as you mentioned, but somehow its not working.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

Try changing options in step 12.

Options on the left side vertcal bar
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I am selecting the correct options for them as well, at least the

are gone now after I changed the Axis2 from 1.5.1 to 1.4.1.

But still I am not able to run the application. All i get is this:



Please help me out with this...

R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. Please try this with Axis2 1.4 instead of 1.5.1. The Eclipse tooling is supported only for 1.4.1. Let us know if you still get the error.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
The error is gone with 1.4.1... But still the application wont run. I get the error:

which i already mentioned.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi Somnath. My apologies. I had not checked your earlier post. Yes, it can be a pain to get this running, no matter how many times you have done it before. Anyway, I used Tomcat 6.0.26 (instead of 5.5 as mentioned in the tutorial) and Axis2 1.4.1.

For your reference, this is my project's WebContent directory structure (after following the tutorial) as seen in Eclipse:

MeraFirst
--WebContent
----axis2-web
------css directory
------Error directory
------images directory
------include directory
------lots of jsp files
------index.jsp
------more jsp files
----META-INF
----WEB-INF
----wsdl

To get this to work, I did the following:

1. Right-click index.jsp
2. Select Run As-->Run on Server
3. Select the configured tomcat server

And it took me to http://localhost:8080/MeraFirst/axis2-web/index.jsp which worked And I get the same 404 error as you do when I go to http://localhost:8080/MeraFirst/ So the tutorial is probably old and not updated for newer releases of Axis2.

You can also browse the WSDL of the Converter service you created by going to http://localhost:8080/MeraFirst/services/Converter?wsdl

And then you can download and install the open source version of SOAP UI. And play with that as well. You can use SOAP UI to generate SOAP requests from a WSDL URL (like the one above), send those requests to the Web Service Endpoint, and then show the SOAP response.

Hope that helps.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Thanks Srini for the help. How did you know that that the URL would be different??? I guess there's no replacement for experience.

But now... In steps 26 and 27 of the tutorial you can see that there are a lot of stub files that are being generated on the Client. Now when I create my client I only have 2 classes and no stubs! And the example shown, is also written using the stubs! Now how come mine doesn't generate any stubs???

I am attaching my directory structure. Please take a look at it.



[Thumbnail for 1.JPG]

R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Comparing notes:
Step 21: Use http://localhost:8080/MeraFirst/services/Converter?wsdl
Step 22: Make sure that Axis2 is selected before proceeding to next step. In my case, Axis was selected by default, and I had to explicitly select Axis2.
Step 24: I clicked on Client Project MeraFirst, overwrote it to MeraFirstClient, and the Client Project Type was "Dynamic Web", i.e. web application
Step 25: My default values were different that in the tutorial, probably due to the newer version of Eclipse or some plug-in:
Service Name: ConverterService (the one for which we are generating a client)
Port Name: Converter (instead of ConverterSOAP11port_http in the tutorial)
Databinding: ADB

Now, my results match yours:
a) a CallbackHandler file
b) a Stub file
c) axis2-web under WebContent, just like in the MeraFirst web service project

Now how come mine doesn't generate any stubs???

It does. As I am sure you know, WorkerStub.java is your generated stub file.

Step 27: And finally, the following client program worked for me:


So: the answer to your question is simple. The wtp (or whatever tool (like WSDL2Java) that generated the code internally) was from an older version that was current at the time the tutorial was written. Now, only two source files are generated. This is expected and ok.

All the best!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Thanks Srini for the code... But by looking at your code I have a few questions. First of all:
I have two generated methods:
ConverterStub and ConverterCallbackHandler. But in the code you have given you have used some other classes as well, like ConverterServiceStub, Celsius2Fahrenheit and Celsius2FahrenheitResponse. Were these classes also coded by you?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
It would be better if you could provide a link which has tutorial with the latest web services updates!
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
If you look at the code, Celsius2Fahrenheit is wtp.ConverterServiceStub.Celsius2Fahrenheit. It is generated and located in the stub file. Here is a tutorial using Netbeans. There are tons of other tutorials on the web. Please search for tutorials for your particular combination of tools.

There is a certain amount of experimentation, and a learning curve involved in this. A few tutorials won't get you very far. Please look for a good book. The book Developing Web Services with Apache Axis2 is one I have heard good things about. All the best!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Facing Problems Running My First WebService
 
Similar Threads
problem with tomcat Native library
Error in FilterStart Struts 2 web app
Tomcat startup Problem
Unable to get Web Service running
Apache Tomcat: startup failed due to previous errors