0

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?

Federico Cristina
  • 2,203
  • 1
  • 19
  • 37

1 Answers1

0

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.

Federico Cristina
  • 2,203
  • 1
  • 19
  • 37