我正在使用 Apache Axis 实现 WebService。该服务接收一个包含以下成员的ParameterBean类作为参数:
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>();
}
加上传统的 getter 和 setter。我实现了一个特殊的构造函数:
public ParameterBean(String userName, String password, int clientID, int orgID) {
this.userName = userName;
this.password = password;
this.clientID = clientID;
this.orgID = orgID;
}
另外,这个类有一些基本的方法,比如:
public void addColumnToMainTable(String columnName, String columnValue) {
addColumnOnTable(mainTable, columnName, columnValue);
}
但是,当我运行 java2wsdl 和 wsdl2java 时;生成的ParameterBean源代码差别很大。方法addColumnToMainTable()没了,生成的构造函数就是这个(和原来的不一样):
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;
}
我的 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>
为什么生成的代码存在差异?我该如何解决?我正在使用轴 1.4。谢谢。
编辑:对我来说更重要的是:我应该使用哪个类(服务器端和客户端)?我的还是生成的?