views:

48

answers:

1

I made a Webservice Operation whose return type is STRING [] Following is the code

@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;**

}

And then i made a Servlet The code of the servlet thing is :

      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
             }

Problem is in my WEbservice Code in RETURN STATEMENT i have attributes of any table and i want to take these attributes to servlet so that i can see them on my front end but what im getting here is the only the LAST ATTRIBUTE

Thanks!

A: 

This is the way u can handle Webservice Operation of String Return type

 @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();
}

}

Sundhas