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 Web service question: Integrating a web service client in existing Tomcat app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service question: Integrating a web service client in existing Tomcat app" Watch "Web service question: Integrating a web service client in existing Tomcat app" New topic
Author

Web service question: Integrating a web service client in existing Tomcat app

Ted Addis
Greenhorn

Joined: Nov 19, 2008
Posts: 11
Hello all,
I created a web service client ( of a WSDL based offsite web service) using Eclipse WTP and tested it using same WTP work bench. When testing Eclipse created an instance of Tomcat and the whole thing run independent of the over all tomcat web project.

My question is , I now wants to make my project become the client so I called the proxy like this

TestServiceSoapProxy myLocalTest = new TestServiceSoapProxy();

and called the method like this..

myLOcalTest.testMethod(500, 200)

all is fine and compiled but I am getting servletException error...

Any idea
Ted Addis
Greenhorn

Joined: Nov 19, 2008
Posts: 11
Ok to put my question in different way, Eclipse created the following and run successfully using its own testing

TestService.java
TestServiceLocator.java
TestServiceSoap.java
TestServiceSoap12Stub.java
TestServiceSoapProxy.java
TestServiceSoapStub.java

My servlet application throws exception the moment I try to instantiate any of the classes from the above.
Any idea ?
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
Exception stack trace might help others to see the cause of problem.


My Blog
Ted Addis
Greenhorn

Joined: Nov 19, 2008
Posts: 11
Vinod,
Thanks for your reply.. Here is my problem. It is too catastrophic that it doesn't even reach to my first statement before my try statement as below..

I have a method inside my helper class that I haven't even start calling in my servlet class.

I introduced a new method in my HelperA.java and doesn't even print my info message. And remeber I am not even calling this method anywhere in my application.

public int getTestRemote()
{
message.info("About to instantiate a TestServiceSoapStub");
try {
TestServiceSoapStub myStub = new TestServiceSoapStub();


}

}

What are the preparations to run a web service client from a Tomcat based application? I mean it looks like some major error. And like I previously said, Eclipse created its own tomcat instant when testing and it worked.. What do I need to do on my Tomcat configuration? in my web.xml or server.xml ? or anywhere ?

Thanks,
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
There are no required Apache Tomcat procedures for allowing an object to call a web service.

I suggest creating a plain old Java class that can be run from a command-line and call the web service from this class (using command line). Once this is working, copy the code into a class that is part of the web application. (Make sure that you have all of the required classes in the Tomcat classpath)
[ November 20, 2008: Message edited by: James Clark ]
Ted Addis
Greenhorn

Joined: Nov 19, 2008
Posts: 11
Thanks James,
I see your point on using POJO in stead of relying on Eclipse WTP. But this is my situation,
1. I have a Tomcat application that is running on Eclipse 3.4/ Tomcat 5.5/ Jdk 1.5 so I thought WTP would be a good choice to be able to integrate easily.

2. I have zero experience with web service. So there is no way I can generate all the Stubs, Proxy, etc classes in short period of time.

3. Axis2 despite its easy look, may be it is me or I don't know but I just can't get it.

And when I was able to test the web service on its own using WTP explorer, it just made sense to me to try to make it to work with in my existing application.

Since my last question, I made sure I include all Axis2 jar files same as WTP has it in my class path but still getting same error.
Do I need to mess with my web.xml file ? But I am calling the generated Stub class with in my existing Helper class so I don't see the need. Please let me know any suggestions you may have.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
It is unclear why and how you have chosen Eclipse for the "client." The client of a web service is another application. You should engage with someone with knowledge of what this WTP thing is and figure out how it relates to the client application that calls the web service.

Axis2 is not a good pick for beginner's. I suggest that you look to Axis1. This is a simpler implementation which makes it eary to learn with. The strength is in the service itself. Axis1 implements and provides all of the services required by the SOAP Engine API. This includes complex handler support for WS-Security, XMLSignature, and the other relevant service-based API.

There are no modifications to any of the Tomcat configuration files.

Your best bet is to learn how to develop web service client code with straight Java classes/objects. Once you understand this, you will not be confined by a tool such as Eclipse.
[ November 20, 2008: Message edited by: James Clark ]
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
See if this helps in anyway-
http://blog.vinodsingh.com/2008/09/building-jax-ws-web-service.html
http://blog.vinodsingh.com/2008/09/jax-ws-web-service-and-jboss.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service question: Integrating a web service client in existing Tomcat app