Wsimport clientjar Option

Wsimport clientjar Option explains about generating Java Code From A WSDL Document and packed into a jar, So that Client Can Invoke/Consume The Service

I am showing here, an example of generating java code from WSDL document using wsimport tool.

You can also use CXF Client , if you need more custom features like adding logging,interceptor etc.

Reference -> http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

For deploying the service, you can follow this tutorial CXF Web Service Tutorial. After the deployment you can access the url

http://localhost:8080/CXFTutorial/ChangeStudent?wsdl

Required Libraries

You need to download

  1. JDK 7

Now I am invoking wsimport with -clientjar option from console like following

C:\>wsimport -keep -clientjar wsdlclient.jar http://localhost:8080/CXFTutorial/ChangeStudent?wsdl
parsing WSDL...



Generating code...


Compiling code...

Run Client

You need wsdlclient.jar must be in classpath(generated using Wsimport client.jar on above steps) in order to run this client.

package com.client;

import com.student.ChangeStudentDetails;
import com.student.ChangeStudentDetailsImplService;
import com.student.Student;

// wsimport clientjar example

public class Main {

 
public static void main(String[] args) {
   
ChangeStudentDetailsImplService service = new ChangeStudentDetailsImplService();
    ChangeStudentDetails changeStudentDetailsImplPort = service.getChangeStudentDetailsImplPort
();
    Student student =
new Student();
    student.setName
("Rockey");
    Student changeName = changeStudentDetailsImplPort.changeName
(student);
    System.out.println
("Server said: " + changeName.getName());
 
}

}
Output
Server said: Hello Rockey

 











1 Responses to "Wsimport clientjar Option"
  1. Rockey 2012-10-30 09:13:44.0

Your email address will not be published. Required fields are marked *