You want a quick and simple way to call a web service that is already deployed.
Follow these basic steps:
Make sure that you are running Java SE 6.
wsimport tool by passing it the location
of your service’s WSDL. This will generate classes that conform to
the WSDL messages, and convenience classes to invoke it.
Create a class with a main method that will invoke the service use the generated classes.
Compile and run the program.
These steps represent an easy way to call an existing web service using JAX-WS. You can then transfer this basic idea onto more sophisticated Java projects. By doing everything from scratch, outside any IDE, you can better understand how the pieces all work. Let’s follow the steps to create the client and call a service.
Here you’ll use a service that is available publicly for free at
http://WebServiceX.net. If you are testing against
another service, such as one within your own organization, just replace
the WSDL location string. The
wsimport tool will then of course generate a
different set of classes that match your WSDL, and you’ll have to put
the objects together in a way that creates a meaningful message for that
service. But the basic idea is always the same.
The web service you’ll invoke is described at http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=44. It’s called USA Weather Forecast: you pass it a zip code, and it returns a forecast. I chose this service because while ...