[英]Generated source classes using Axis java2wsdl / wsdl2java differs from original
我正在使用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>();
}
加上传统的吸气剂和吸气剂。 我实现了一个特殊的构造函数:
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>
为什么生成的代码存在差异? 我该如何解决? 我正在使用Axis 1.4。 谢谢。
编辑:对我来说更重要的是:应该使用哪个类(服务器端和客户端)? 是我的还是生成的?
好吧,认真阅读Axis文档 ,生成的类将有所不同,因为WSDL不包含有关代码实现的任何信息,因此不包含默认构造函数,并且没有getters / setter之外的其他方法。
对于客户端,我可以使用生成的类或原始类,两者都可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.