The wsimport tool reads a WSDL and generates all the required artifacts for web service development, deployment, and invocation. The wsimport tool supports the top-down approach to developing JAX-WS Web services, where you are starting from a wsdl.
wsimport tool is assembled in JDK and can be found in bin folder. To create SOAP web service artifacts open command prompt in any location and run command like
wsimport -keep http://localhost:8081/service/Custom.wsdl
It will generate necessary classes in packages alongwith Client class and Service interface.
Now create a new Java project. Copy all these classes and create a new main java class that will call service.
——–
public static void main(String[] args) {
CustomService client = new CustomService();
CustomSoapPort service = client.getCustomSoapPortSoap11();
//Set authenticator if required.
Authenticator myAuth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(“username”,
“password”.toCharArray());
}
};
Authenticator.setDefault(myAuth);
GetAllCustomFeeRequest req = new GetAllCustomFeeRequest();
GetAllCustomFeeResponse response = service.getAllCustomFee(req);
System.out.println(response.getCustomFee().size());
}
————–
This will call service and prints response. Simple…
I hope this article is quite helpful to understand how client support code can be generated using wsimport command.