2009-12-08 24 views
1

我做了一個WebService操作,其返回類型爲string [] 以下是代碼問題在得到來自web服務屬性Servlet時操作的web服務的返回類型的String []

@WebMethod(operationName = "authorize") 
public String [] authorize(@WebParam(name = "Username") 
String Username) { 
    CAuthorization CA = new CAuthorization(); 
    String [] Result= null; 
     try { 
     Result = CA.CheckAuthorization(Username); 
    } catch (SQLException ex) { 
     Logger.getLogger(WS_Authentication.class.getName()).log(Level.SEVERE, null, ex); 
    } 

    **return Result;** 

} 

然後我做一個Servlet 的servlet的東西的代碼是:

 try { // Call Web Service Operation 


       java.lang.String result = null; 
        result = port.authorize(Username); 
       out.println("Result = "+result); 
      } catch (Exception ex) { 
       // TODO handle custom exceptions here 
      } 

問題是在我的web服務代碼中return語句我有任何表 的屬性,我想利用這些屬性與Servlet這麼個在我可以看到他們在我的前端 但即時到達這裏是唯一的最後的屬性

謝謝!

+0

請解決您的標記在問題的WebService操作的方式。並且避免在你的文字中使用大寫字母。沒有人(理智)在這裏喜歡大聲喊叫。 – Steen 2010-01-28 11:02:43

回答

0

這是ü可以處理字符串返回類型

@WebMethod(operationName = "authorize") 
    public String authorize(@WebParam(name = "Username") 
    String Username) { 

    CAuthorization CA = new CAuthorization(); 
    StringBuffer result = new StringBuffer(); 
    try { 
     if (CA.CheckAuthorization(Username).length > 0) { 
      result.append(CA.CheckAuthorization(Username)[0]); 
      for (int i = 1; i < CA.CheckAuthorization(Username).length; i++) { 
       result.append(","); 
       result.append(CA.CheckAuthorization(Username)[i]); 
      } 
     } 
    } catch (SQLException ex) { 
     Logger.getLogger(WS_Authentication.class.getName()).log(Level.SEVERE, null, ex); 
    } 
    //TODO write your implementation code here: 
    return result.toString(); 
} 

}