aspose file tools*
The moose likes Java in General and the fly likes how to call existing webservice in my java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to call existing webservice in my java class" Watch "how to call existing webservice in my java class" New topic
Author

how to call existing webservice in my java class

prashant fusate
Greenhorn

Joined: Aug 24, 2005
Posts: 16
Dear friends
I have a requirement that webservice is running on net and i want to call that webservice in my stand alone java class. how can i do this

Please send me an example with souce so that i can understand it

Because I have new to this topic

Thanks
prashant


psfusate
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Prashant,

Take a look at the Apache Axis project http://ws.apache.org/axis/. This will give you the tools for working with web services.

With Axis comes a tool called wsdl2java which will generate the necessary code for communicating with a web service. You simply run it with the URL to the web service as an argument.

You can then use the classes it generates to call methods on the web service.


SCJP 1.4, www.gsi3d.org.uk
prashant fusate
Greenhorn

Joined: Aug 24, 2005
Posts: 16
Hi,
Thanks for the update.

in the replied link I do not found how to call web service through my stand alone java class please let me know how to call web service via WSDL file nsing my java class what are the jar file required to call it.



Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
The basic steps you need to go through are:
1) obtain the WSDL of the web service you want to use
2) run the wsdl2java tool (it's part of Axis) to create client-side classes
3) adapt the classes to your circumstances

There are a few introductory articles about this in the Web Services FAQ, which is linked in my signature. Most of them also talk about setting up the web service itself, but you skip that part.


Ping & DNS - my free Android networking tools app
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
You will need to download Axis from that site and then browse the documentation (e.g. the user guide).

Specifically take a look at this section:

http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL

which will tell you how to use the wsdl2java tool to generate some Java classes which you can then use in your stand-alone application to call the webservice. It generates these classes for you based on the WSDL of the web service in question, so that you end up with stubs for the object types and associated method calls for that particular web service.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
By the way, there is a web services forum on the site
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to call existing webservice in my java class