• 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

doubt: how to make a client (servlet) consuming webservice

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.
my doubt:
I made a simple webservice:



how I would make a "Client-Servlet"?

for example: a myfile.jsp (containg two forms to put the numbers n1 and n2, and a bottom to calculate) and the myservlet.class to consume the webservice and show the result.

myfile.jsp -> myservlet.class -> webservice -> myservlet.class -> result.jsp

is it possible?

please, no IDE.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's possible. In fact I can't tell what barriers you imagine are in your way. Perhaps you could explain in a little more detail why you are having trouble doing that little example.
 
ronald silva
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, Paul, how are you?
I am learning java and webservices.
I made the webservice using AXIS. (I saw an example in the internet).
and... the internet teaches how to make a client to webservice using java without servlets.
I need to learn to make a client using servlets.
I went to the shopbooks, libraries, and I didnt find any book about client-servlet consuming the webservice.
can you help me?


 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You already know how to write Java code which consumes a web service. So if you want to write a servlet which consumes a web service, you would take that Java code and insert it into the servlet.
 
ronald silva
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, in the site thai I have seen the example of webservice, there is the code:



how do I adapt the code above to servlet-code-client?

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(I put code tags around your code so it's a bit more readable. Indented code would have been even nicer... anyway have a look at UseCodeTags for more information about how to do that in future.)

Anyway here's the relevant code which consumes the web service:



You'd start by putting that into the get() method of your servlet, or whatever method is being called when a request is sent to it. But you want your inputs to come from the request, so you would remove the hard-coding of the "param" variable and replace that by something which gets two numbers from the request parameters. Then you'd replace the last line by something which puts the result into the servlet's response.
 
ronald silva
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Paul,
well, and if we forget the form.jsp (with the forms)?
lets keep the servlet with fix parameters (number one = 15 and number two = 15)
and now? what do we need to do the servlet works?

this is the wsdl:



I am lost...
 
ronald silva
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please, could you show me the complete code of servlet?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course not. We aren't a service to do other people's work here.

But it should be simple enough. Why don't you start with a servlet which receives two parameters and just echoes them back to the requester? Nothing more than that. Forget about the web service consumer business for now, you can add that in later.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic