permaculture playing cards*
The moose likes Servlets and the fly likes Calling a servlet from a java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling a servlet from a java class" Watch "Calling a servlet from a java class" New topic
Author

Calling a servlet from a java class

Nitin Mehhta
Ranch Hand

Joined: May 18, 2004
Posts: 48
I want to call a servlet residing in a websphere server through a java application. The servlet in turn would route my request to a webservice. The webservice is returning a SOAP output ( a string ). Now what i want basically is to transfer back this string to my calling application. How do I do this. Please send me some code snippet or any link which can serve as a starting point on this.

Thanks
damien malone
Ranch Hand

Joined: May 06, 2003
Posts: 35
In order for your application to connect to the servlet, you will have to open up a HTTP socket to the URL of your servlet. A brief discription of the principles, and some sample code can be found here

http://hplasim2.univ-lyon1.fr/c.ray/bks/java/htm/ch26.htm

HTH
Damien
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Why have the extra servlet in the middle? Why not just call the Web Service from the calling application using the standard SOAP client classes?

Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Nitin Mehhta
Ranch Hand

Joined: May 18, 2004
Posts: 48
Hi you are right in asking this question. Actually what I needed was a single point entry for all the webservices into my application server. Another point of contention was that one of my web service would take a long time in doing it's job. So I wanted to just initiate the service through the servlet and return back to the client and let the service take it's time. Can you suggest any thing which will run the webservice in the back ground. i know this is not the correct forum for this but since this has come up so I'm asking this. I can use the "invokeOneSWay" method but in it's API it is written that "NOTE: the return immediately part isn't implemented yet ".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling a servlet from a java class
 
Similar Threads
How to pass an XML to a servlet.
XML result as a String
handling SOAP fault in JAVA
What is the difference between servlet and webservice.
is it possible to make a servlet to a webservice?