Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling web services from Spring application

 
megha Ranjan
Greenhorn
Posts: 10
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know how do we integrate servlets/jsp with restful web services. Please help. Using spring3.0,jibx and eclipse.
 
Tim Moores
Bartender
Posts: 2894
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "integrate"? JSPs have nothing to do with web services. Servlets are generally used for implementing web services, but the WS framework does that, you wouldn't have to write a servlet.
 
megha Ranjan
Greenhorn
Posts: 10
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:What do you mean by "integrate"? JSPs have nothing to do with web services. Servlets are generally used for implementing web services, but the WS framework does that, you wouldn't have to write a servlet.


I mean i have developed one web service and now i want to call that web service on click of button from a jsp page. How can that be achieved using spring.
 
Tim Moores
Bartender
Posts: 2894
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what Spring has to do with this - are you using some WS library that's related to Spring? If so, there's probably a page that lists all available WS and their URLs; the documentation should tell you where to find that.

Then you'd use the URL of that service in your HTML/JSP page (maybe as the action attribute of a form that gets submitted at the click of a button).
 
Pankaj Kumarkk
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You basically have to write a web service client.
If you want to call as web service from click of a button on a jsp then below is what you would have to do:
1. Write a jsp page which takes in input parameter for the web service method
2. Write a servlet to recieve the request from the jsp and get all the input parameters
3. Generate the web service client side artifacts
4. Call the web service using the client proxie. This code for calling can be written in the servlet itself
5. Recieve the response from web service. Use that response to populate the result jsp

I do not know if spring provides all of this automatically. These are the steps you would need to do to invoke a web service from a jsp.

PS: Calling a web service from a jsp makes sense only if you are consuming web services in your web application.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point, the OP already has written the web service using Spring. He just wants to call a web service from a button on the JSP page, so actually, this isn't a Spring questions. This is just a simple. What is the URL for the web service and call it from the button on the page.

I am moving this back to the JSP forum. Which I am assuming is where it originated.

Thanks and good luck.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic