Wsimport:
Wsimport tool is used to parse the WSDL file and generate
the necessary files (which are known as portable artifacts) for a web service
client to access the published web service. This tool comes along with the JDK
bundle ($JDK/bin). We can use this tool
to consume a free web services site available over the network like
webservicex.net. These websites used to provide the WSDL file for the free web
services. So we can parse these WSDL file and generate the web service client
with the help of wsimport tool.
How to use wsimport?
We are going to consume the Global Weather web service
available in the site www.webservicex.net.
WSDL schema location provided is. http://www.webservicex.net/globalweather.asmx?WSDL
To generate web service client, issue the following command
from the command promt.
C:\webservice\> wsimport http://www.webservicex.net/globalweather.asmx?WSDL
The wsimport will parse the WSDL file provided and generate
the necessary Java class files (.java) to consume the service. After it will
compile these generated .java files and produce the .class files. Once it
generates the .class files it will remove the .java (source file). You can
retain it by issuing the following argument in the wsimport.
This –keep will retain the .java src files.
Copy this .java source files to your workspace.
This Global Weather web service has two operations
GetCitiesByCountry
GetWeather
No comments:
Post a Comment