aspose file tools*
The moose likes Web Services and the fly likes Passing array of strings to a netbeans WS method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Passing array of strings to a netbeans WS method" Watch "Passing array of strings to a netbeans WS method" New topic
Author

Passing array of strings to a netbeans WS method

Pranab Das
Greenhorn

Joined: Dec 02, 2004
Posts: 1
Hi,

I want to pass an array of strings to a WS method in the following manner, which is not working. I am not an efficient programmer. Can anyone suggest some piece of code? I will appreciate any help.

package ....;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import java.net.*;
import java.io.*;
import java.util.*;

@WebService()
public class MyClass {
@WebMethod(operationName = "abc")
public String abc(@WebParam(name = "def") String [] def) {
try{
String string = "";
for(int i=0;i<def.length; i++){
string += def[i] + " ";
}
return (string);
//
} catch (Exception ex) {
Logger.getLogger(MyClass.class.getName()).log(Level.SEVERE, null, ex);
return ex.toString();
}
}
}

P.S. I hit upon a not elegant solution that is following:
public String abc(@WebParam(name = "def") String def) {
String tmp [] = null; // to clean any leftover
tmp = def.split(" ");
String string = "";
for (int i = 0; i < tmp.length; i++){
string += tmp[i] + "%20";
}
return(string);

[ October 19, 2007: Message edited by: Pranab Das ]
[ October 19, 2007: Message edited by: Pranab Das ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing array of strings to a netbeans WS method