我做了一個web服務,它只是簡單地顯示來自數據庫的用戶數據。但是當我運行客戶端時,我一直在獲取這個異常。在基本的webservice中獲得例外
Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element at [row,col {unknown-source}]: [1,110]
/////////////////////這是web服務代碼////////////////// //////////////
@WebMethod(operationName = 「viewUserData」)
public ArrayList viewUserData() {
//TODO write your implementation code here:
Statement stmt = null;
ResultSet rs = null;
String query = "";
//ArrayList<HashMap> list = new ArrayList<HashMap>();
ArrayList list = new ArrayList();
try {
String connectionURL = "jdbc:oracle:thin:@p5";
Connection connection = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(connectionURL, "backconnect", "backconnect");
query = "select * from users";
stmt = connection.createStatement();
rs = stmt.executeQuery(query);
while(rs.next()){
/*HashMap<String,Object> map = new HashMap<String,Object>();
map.put("USER_ID", rs.getString("USER_ID"));
map.put("NAME", rs.getString("NAME"));
map.put("SHORT_NAME", rs.getString("SHORT_NAME"));
map.put("PASSWORD", rs.getString("PASSWORD"));*/
SetData sdata = new SetData();
sdata.setUSER_ID(rs.getString("USER_ID"));
sdata.setNAME(rs.getString("NAME"));
sdata.setSHORT_NAME(rs.getString("SHORT_NAME"));
sdata.setPASSWORD(rs.getString("PASSWORD"));
/*list.add(rs.getString("USER_ID"));
list.add(rs.getString("NAME"));
list.add(rs.getString("SHORT_NAME"));
list.add(rs.getString("PASSWORD"));*/
list.add(sdata);
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return list;
}
SetData的是一個Java bean ////////// //////////這是客戶代碼///////////////////
package1.GetUserDataService service = new package1.GetUserDataService();
package1.GetUserData port = service.getGetUserDataPort();
// TODO process result here
java.util.List<java.lang.Object> result = port.viewUserData();
out.println("Result = "+result);
I我陷入了這一點。如何解決這個問題。
在客戶端這一行上,它拋出了一個異常java.util.List result = port.viewUserData(); –
2011-04-20 05:29:01
@Java_NewBie:客戶端可能會以任何方式報告錯誤,但您應該能夠看到發生了什麼並回來。 – 2011-04-20 05:32:18
@Java_NewBie:除了Jon推薦:使用[soapUI](http://www.eviware.com/soapUI/soapui-products-overview.html)測試webservice - 如果* that *有效並且消息看起來不錯,然後在客戶端進行調查。 – 2011-04-20 05:54:21