How to generate java classes from WSDL file

前端 未结 8 659
一生所求
一生所求 2020-12-02 17:09

I am working towards an android application. I need to use a web service. I have a wsdl file but I want to convert that into java so that I can use its functions in my Java

8条回答
  •  被撕碎了的回忆
    2020-12-02 17:48

    Just to generate the java classes from wsdl to me the best tool is "cxf wsdl2java". Its pretty simple and easy to use. I have found some complexities with some data type in axis2. But unfortunately you can't use those client stub code in your android application because android environment doesn't allow the "java/javax" package name in compiling time unless you rename the package name.

    And in the android.jar all the javax.* sources for web service consuming are not available. To resolve these I have developed this WS Client Generation Tool for android.

    In background it uses "cxf wsdl2java" to generate the java client stub for android platform for you, And I have written some sources to consume the web service in a smarter way.

    Just give the wsdl file location it will give you the sources and some library. you have to just put the sources and the libraries in your project. and you can just call it in some "method call fashion" just we do in our enterprise project, you don't need to know the namespace/soap action etc. For example, you have a service to login, what you need to do is :

    LoginService service = new LoginService ( );
    Login login = service.getLoginPort ( );
    LoginServiceResponse resp = login.login ( "someUser", "somePass" );
    

    And its fully open and free.

提交回复
热议问题