简体   繁体   中英

Generated source classes using Axis java2wsdl / wsdl2java differs from original

I'm implementing a WebService with Apache Axis. This service receives as a parameter a ParameterBean class that contains these members:

public class ParameterBean {
    protected String userName   = "";
    protected String password   = "";
    protected int    clientID   = 0;
    protected int    orgID  = 0;
    protected HashMap<String, String> mainTable = new HashMap<String, String>();
}    

Plus traditional getters and setters. I've implemented a special constructor:

public ParameterBean(String userName, String password, int clientID, int orgID) {
    this.userName = userName;
    this.password = password;
    this.clientID = clientID;
    this.orgID = orgID;
}

Adittionaly, this class has some basic methods like:

public void addColumnToMainTable(String columnName, String columnValue) {
    addColumnOnTable(mainTable, columnName, columnValue);
}

However, when I run java2wsdl and wsdl2java; the generated ParameterBean source code differs a lot. The method addColumnToMainTable() is gone, and the constructor generated is this one (which differs from the original):

public ParameterBean(
    int clientID,
    java.util.HashMap mainTable,
    int orgID,
    java.lang.String password,
    java.lang.String userName) {
    this.clientID = clientID;
    this.mainTable = mainTable;
    this.orgID = orgID;
    this.password = password;
    this.userName = userName;
}

My build.xml:

<target name="generateWSDL" description="Generates wsdl files from the java service interfaces">  
<mkdir dir="${wsdl.dir}"/>  
<axis-java2wsdl classpathref="classpath"  
    output="${wsdl.dir}/ExampleWS.wsdl"  
    location="http://localhost:8080/axis/services/ExampleWS"  
    namespace="org.example.ws"  
    classname="org.example.ws.ExampleWS">  
</axis-java2wsdl>  
</target>  

<target name="generateWSDD" description="Generates wsdd files from the wsdl files">  
<mkdir dir="${wsdd.dir}"/>  
<axis-wsdl2java  
    output="${wsdd.dir}"  
    deployscope="Application"  
    serverside="true"  
    url="${wsdl.dir}\ExampleWS.wsdl">  
</axis-wsdl2java>  
</target>

Why the differences in the generated code? How can I fix it? I'm using Axis 1.4. Thanks.

EDIT: What's more important to me is: which class should should I use (server-side and client-side)? Mine or the generated one?

Well, reading carrefully the Axis documentation , the generated classes will differ because the WSDL does not contain any information about code implementation, thus the default constructor and no other methods beyond getters/setters.

For the client, I can use the generated class or the original one, both work just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM