Jax-ws 2.1 - problems returning hashtable and hashmap
843833Jul 13 2007 — edited Jul 16 2007Hi,
We're developing a set of applications that communicate via web services.
The company decided that to do this we should use jax-ws 2.1.
Everything is going ok, its really easy to use, except for a web method that returns a java.util.Hashtable.
In the endpoint there's no problem, it compiles and deploys to a tomcat 5.5 without a problem.
The client can access the wsdl via url, download it and create the necessary files (we use netbeans 5.5 for this).
We can invoke the method getConfig without a problem, but the object returned only has the java.lang.Object 's methods, not the java.util.Hastable 's .
Endpoint:
package xxx.cdc_pm_i;
import java.util.Hashtable;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.*;
@WebService()
public class cdc_pm_i{
@WebMethod
public Hashtable getConfig() {
Hashtable<String,String> config = new Hashtable<String,String>();
config.put("1","1");
config.put("2","2");
return config;
}
}
Client:
try { // Call Web Service Operation
xxx.CdcPmIService service = new xxx.cdc_pm_i.CdcPmIService();
xxx.cdc_pm_i.CdcPmI port = service.getCdcPmIPort();
// TODO process result here
xxx.cdc_pm_i.Hashtable result = port.getConfig();
} catch (Exception ex) {
ex.printStackTrace();
}
I'm fairly unexperienced in Web Services and i have no idea why this works for any kind of return object (as long as its serializable) and has this problem with hashtables and hashmaps.
Any idea on how to solve this?
Thanks in advance,
Rui