Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a servlet from a java class

 
Nitin Mehhta
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nitin Mehhta
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic