• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Call Web Service from Servlet

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
Since i am newbie to web services . i have started developing a simple application which has a login page and have to do its simple validation

For this i created a simple web service which is used for login validation, i have its WSDL link and created the Client...

Now i wanted to use this on my JSP page..Following are the steps i used,

1) Created the Login JSP

2) When Submit button is clicked the Servlet is called

3) This servlet calls the web service by calling its stub and then the respective method(Note: I had included the service and the client jar in my classpath n this is how i get the service)

IDE used : Eclipse Indigo
Server : Tomcat v7

I wanted to ask IS THIS THE CORRECT WAY OF CONSUMING WEB SERVICES USING JSP n SERVLETS..or is their any other way out?
 
Greenhorn
Posts: 10
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should catch your Web service in some backend logic code and parse the result into your JSP. Not directly in your JSP.

I don't even think it is possible??

Just use something like Axis to parse the web service into a backend logic class.

I hope this helps
 
arriesh chellu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jimmy,
Can you please elaborate what do you mean by "parse web service"..?

I am using Apache AXIS 2 and after creating the client and the service projects i have included them in my main project which has the actual web application?

And then in my servlet i get the Stub of the client and then call the respective service method..

I too think its better to leave JSP out of the picture...but there should be some mechanism by which our business logics written in servlets use these web services...

Just wanted to know that the process i followed of including the client and the service jar in the main project is appropriate or not?
 
Jimmy Ruts
Greenhorn
Posts: 10
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I understand it better now. And If I understand it correctly then I think you are doing a good job.

You have your JSP for the view, you have your Servlet for initialising and generating the things you need to show in a JSP again, and in that Servlet you get your data from your Webservice stub/class.

That seem pretty ok to me.

I am by no means a java Guru or Expert (intermediate at best), but in my opinion this is good. Maybe a more experienced person has something different to say about this...
 
arriesh chellu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jimmy for the quick reply...

But will need an expert suggetion too on this....

reply
    Bookmark Topic Watch Topic
  • New Topic