2012-08-22 28 views
0

我正在使用Apache Axis實現WebService。該服務作爲參數接收一個ParameterBean類,它包含以下成員:使用Axis java2wsdl/wsdl2java生成的源類不同於原始

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; 
} 

Adittionaly,這個類有像一些基本的方法:

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。謝謝。

編輯:更重要的是我應該使用哪個類(服務器端和客戶端)?我的還是生成的?

回答

0

好吧,仔細閱讀Axis documentation,生成的類將有所不同,因爲WSDL不包含任何有關代碼實現的信息,因此它是缺省構造函數,除了getters/setters之外沒有其他方法。

對於客戶端,我可以使用生成的類或原始類,兩者都工作得很好。

相關問題