To generate a stub/proxy client from a WSDL file, you need to download Axis from the Apache website This tip will work for jdk1.4.x or above.
Suppose you have a WSDL file named Login.wsdl and you’re working on the directory (in Windows, c:wstest). Just follow these steps:
- Set the classpath:
C:wstest>set classpath=%CLASSPATH%;axis.jar;axis-ant.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar;jaxrpc.jar;log4j-1.2.8.jar;saaj.jar;wsdl4j-1.5.1.jar;c:wstest
- Set the Java path to java org.apache.axis.wsdl.WSDL2Java Login.wsdl.
- Execute the following command to generate the necessary classes:
Login.javaLoginLocator.javaLoginSoap.javaLoginSoapStub.java
See below for the sample files.
- Instantiate the XXXLocator class and invoke getXXXSoap() to get a XXXSoap instance.
- Use the XXXSoap instance to call the webservice methods.
- Instantiate the LoginLocator class and invoke getLoginSoap() to get a LoginSoap instance.
- Using the LoginSoap instance to call the webservice methods:
LoginLocator locator = new LoginLocator(); LoginSoap soap = locator.getLoginSoap(); soap.xxxMethod();