RE: How to pass a HashMap
I reported the same issue in 2.0.3 a while back, and I did have my Map specified as Map. (It was a service that had previously worked under XFire.) I got no response, so I switched to JAXB and just wrapped the Map inside a bean. -Original Message- From: Benson Margulies [mailto:[EMAIL PROTECTED] Sent: Monday, February 25, 2008 10:20 AM To: cxf-user@incubator.apache.org Subject: Re: How to pass a HashMap Please try my suggestion of declaring Map in your SEI instead of just 'map'. On Mon, Feb 25, 2008 at 10:04 AM, Li, Weiye <[EMAIL PROTECTED]> wrote: > Should be the latest one:2.0.4 > Thanks for the reply. > > > On 2/23/08 11:49 AM, "Benson Margulies" <[EMAIL PROTECTED]> wrote: > > What version of CXF have you got? > > > On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > > > The CXF document says that Aegis data binding can even works on Map. I > > tried this, but it always return an empty one. Here's my testing codes. > Did > > I miss something? Or I need to write special config file? > > > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > ParameterStyle.WRAPPED) > > public interface EmicroService { > > @WebMethod > > @RequestWrapper(className="test.model.Employee", > > localName="employee", targetNamespace=" > > http://test.emicro/types ") > > @Oneway > > public void addEmployee(Employee emp); > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > @ResponseWrapper(className="java.util.HashMap", > > localName="EmployeesMap", targetNamespace=" > > http://test.emicro/types";) > > public Map getEmployeesMap(); > > > > } > > > > > > > > > > > > public static void main(String args[]) throws Exception { > > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > > > factory.setServiceClass(test.EmicroService.class); > > > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService > "); > > > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > > > > > EmicroService client = (EmicroService)factory.create(); > > > > > > > >// add 2 employees here, then > > > > > > > >Map emap = client.getEmployeesMap(); > > > >logger.info(emap); > > > > > > > >System.exit(0); > > > >} > > > > > > > > The backend configuration is just following the CXF tutorial > > > > > > > > > > > > > class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > > > > > > address="/EmicroService"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > Any advice? Thanks > > > > > > > > > >
Re: How to pass a HashMap
On Monday 25 February 2008, Benson Margulies wrote: > The use of HashMap as a JAX-WS wrapper type may be a problem. Let me > try the Map experiment in my testbed. Uhh yea. In general, unless you REALLY know what you are doing, for code first, don't put @RequestWrapper and @ResponseWrapper annotations. Setting the classname in them to something other than a properly constructed wrapper type can definitely lead to issues. In this case, if you wanted to use them, you would have to create a bean like: class GetEmployeesMap { Map _return; getReturn getter setReturn setter } Even then, I'm not sure it would work as I don't know how or if aegis can deal with the wrapper types. So, in summary, don't use them.Unless the code generator has specifically put them there (wsdl2java), ignore them. Dan On Monday 25 February 2008, Benson Margulies wrote: > The use of HashMap as a JAX-WS wrapper type may be a problem. Let me > try the Map experiment in my testbed. > > On Mon, Feb 25, 2008 at 10:29 AM, Li, Weiye <[EMAIL PROTECTED]> wrote: > > I think I may have to declare .aegis.xml. > > It was my 2nd try (I mean, use Map only). I did use Map > Employee> on my first try and the outcome is the same: empty map > > returned. > > > > On 2/24/08 12:09 PM, "Benson Margulies" <[EMAIL PROTECTED]> > > wrote: > > > > It does work. But you have to tell it what's in the map. Either > > declare the > > type as > > > > Map, or use a .aegis.xml file to tell it. > > > > > > @WebService(name="EmicroManager", > > > > targetNamespace="http://test.emicro";) > > > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > > > ParameterStyle.WRAPPED) > > > > public interface EmicroService { > > > > @WebMethod > > > > @RequestWrapper(className="test.model.Employee", > > > > localName="employee", targetNamespace=" > > > > http://test.emicro/types ") > > > > @Oneway > > > > public void addEmployee(Employee emp); > > > > > > > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > > > @ResponseWrapper(className="java.util.HashMap", > > > > localName="EmployeesMap", targetNamespace=" > > > > http://test.emicro/types";) > > > > public Map getEmployeesMap(); -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: How to pass a HashMap
The use of HashMap as a JAX-WS wrapper type may be a problem. Let me try the Map experiment in my testbed. On Mon, Feb 25, 2008 at 10:29 AM, Li, Weiye <[EMAIL PROTECTED]> wrote: > I think I may have to declare .aegis.xml. > It was my 2nd try (I mean, use Map only). I did use Map > on my first try and the outcome is the same: empty map returned. > > On 2/24/08 12:09 PM, "Benson Margulies" <[EMAIL PROTECTED]> wrote: > > It does work. But you have to tell it what's in the map. Either declare > the > type as > > Map, or use a .aegis.xml file to tell it. > > > > > > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro";) > > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > > ParameterStyle.WRAPPED) > > > public interface EmicroService { > > > @WebMethod > > > @RequestWrapper(className="test.model.Employee", > > > localName="employee", targetNamespace=" > > > http://test.emicro/types ") > > > @Oneway > > > public void addEmployee(Employee emp); > > > > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > > @ResponseWrapper(className="java.util.HashMap", > > > localName="EmployeesMap", targetNamespace=" > > > http://test.emicro/types";) > > > public Map getEmployeesMap(); > > > > >
Re: How to pass a HashMap
I think I may have to declare .aegis.xml. It was my 2nd try (I mean, use Map only). I did use Map on my first try and the outcome is the same: empty map returned. On 2/24/08 12:09 PM, "Benson Margulies" <[EMAIL PROTECTED]> wrote: It does work. But you have to tell it what's in the map. Either declare the type as Map, or use a .aegis.xml file to tell it. > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > ParameterStyle.WRAPPED) > > public interface EmicroService { > > @WebMethod > > @RequestWrapper(className="test.model.Employee", > > localName="employee", targetNamespace=" > > http://test.emicro/types ") > > @Oneway > > public void addEmployee(Employee emp); > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > @ResponseWrapper(className="java.util.HashMap", > > localName="EmployeesMap", targetNamespace=" > > http://test.emicro/types";) > > public Map getEmployeesMap(); > >
Re: How to pass a HashMap
Please try my suggestion of declaring Map in your SEI instead of just 'map'. On Mon, Feb 25, 2008 at 10:04 AM, Li, Weiye <[EMAIL PROTECTED]> wrote: > Should be the latest one:2.0.4 > Thanks for the reply. > > > On 2/23/08 11:49 AM, "Benson Margulies" <[EMAIL PROTECTED]> wrote: > > What version of CXF have you got? > > > On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > > > The CXF document says that Aegis data binding can even works on Map. I > > tried this, but it always return an empty one. Here's my testing codes. > Did > > I miss something? Or I need to write special config file? > > > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > ParameterStyle.WRAPPED) > > public interface EmicroService { > > @WebMethod > > @RequestWrapper(className="test.model.Employee", > > localName="employee", targetNamespace=" > > http://test.emicro/types ") > > @Oneway > > public void addEmployee(Employee emp); > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > @ResponseWrapper(className="java.util.HashMap", > > localName="EmployeesMap", targetNamespace=" > > http://test.emicro/types";) > > public Map getEmployeesMap(); > > > > } > > > > > > > > > > > > public static void main(String args[]) throws Exception { > > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > > > factory.setServiceClass(test.EmicroService.class); > > > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService > "); > > > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > > > > > EmicroService client = (EmicroService)factory.create(); > > > > > > > >// add 2 employees here, then > > > > > > > >Map emap = client.getEmployeesMap(); > > > >logger.info(emap); > > > > > > > >System.exit(0); > > > >} > > > > > > > > The backend configuration is just following the CXF tutorial > > > > > > > > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > > > > > > address="/EmicroService"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > Any advice? Thanks > > > > > > > > > >
Re: How to pass a HashMap
Should be the latest one:2.0.4 Thanks for the reply. On 2/23/08 11:49 AM, "Benson Margulies" <[EMAIL PROTECTED]> wrote: What version of CXF have you got? On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > The CXF document says that Aegis data binding can even works on Map. I > tried this, but it always return an empty one. Here's my testing codes. Did > I miss something? Or I need to write special config file? > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > ParameterStyle.WRAPPED) > public interface EmicroService { > @WebMethod > @RequestWrapper(className="test.model.Employee", > localName="employee", targetNamespace=" > http://test.emicro/types ") > @Oneway > public void addEmployee(Employee emp); > > > @WebMethod(operationName="getEmployeesAsMap") > @ResponseWrapper(className="java.util.HashMap", > localName="EmployeesMap", targetNamespace=" > http://test.emicro/types";) > public Map getEmployeesMap(); > > } > > > > > > public static void main(String args[]) throws Exception { > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > factory.setServiceClass(test.EmicroService.class); > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService";); > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > EmicroService client = (EmicroService)factory.create(); > > > >// add 2 employees here, then > > > >Map emap = client.getEmployeesMap(); > >logger.info(emap); > > > >System.exit(0); > >} > > > > The backend configuration is just following the CXF tutorial > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > address="/EmicroService"> > > > > > > > > > > > > > > Any advice? Thanks > > >
Re: How to pass a HashMap
It does work. But you have to tell it what's in the map. Either declare the type as Map, or use a .aegis.xml file to tell it. On Sat, Feb 23, 2008 at 1:39 PM, Benson Margulies <[EMAIL PROTECTED]> wrote: > I'm fairly sure I see what the problem is here. You need to either declare > your map with generic args, or use a .aegis.xml file to specify the types. > > On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > > > The CXF document says that Aegis data binding can even works on Map. I > > tried this, but it always return an empty one. Here's my testing codes. Did > > I miss something? Or I need to write special config file? > > > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > ParameterStyle.WRAPPED) > > public interface EmicroService { > > @WebMethod > > @RequestWrapper(className="test.model.Employee", > > localName="employee", targetNamespace=" > > http://test.emicro/types ") > > @Oneway > > public void addEmployee(Employee emp); > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > @ResponseWrapper(className="java.util.HashMap", > > localName="EmployeesMap", targetNamespace=" > > http://test.emicro/types";) > > public Map getEmployeesMap(); > > > > } > > > > > > > > > > > > public static void main(String args[]) throws Exception { > > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > > > factory.setServiceClass(test.EmicroService.class); > > > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService > > "); > > > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > > > > > EmicroService client = (EmicroService)factory.create(); > > > > > > > >// add 2 employees here, then > > > > > > > >Map emap = client.getEmployeesMap(); > > > >logger.info(emap); > > > > > > > >System.exit(0); > > > >} > > > > > > > > The backend configuration is just following the CXF tutorial > > > > > > > > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > > > > > > address="/EmicroService"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > Any advice? Thanks > > > > > > >
Re: How to pass a HashMap
I'm fairly sure I see what the problem is here. You need to either declare your map with generic args, or use a .aegis.xml file to specify the types. On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > The CXF document says that Aegis data binding can even works on Map. I > tried this, but it always return an empty one. Here's my testing codes. Did > I miss something? Or I need to write special config file? > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > ParameterStyle.WRAPPED) > public interface EmicroService { > @WebMethod > @RequestWrapper(className="test.model.Employee", > localName="employee", targetNamespace=" > http://test.emicro/types ") > @Oneway > public void addEmployee(Employee emp); > > > @WebMethod(operationName="getEmployeesAsMap") > @ResponseWrapper(className="java.util.HashMap", > localName="EmployeesMap", targetNamespace=" > http://test.emicro/types";) > public Map getEmployeesMap(); > > } > > > > > > public static void main(String args[]) throws Exception { > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > factory.setServiceClass(test.EmicroService.class); > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService";); > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > EmicroService client = (EmicroService)factory.create(); > > > >// add 2 employees here, then > > > >Map emap = client.getEmployeesMap(); > >logger.info(emap); > > > >System.exit(0); > >} > > > > The backend configuration is just following the CXF tutorial > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > address="/EmicroService"> > > > > > > > > > > > > > > Any advice? Thanks > > >
Re: How to pass a HashMap
This is now CXF-1451. Please comment there, but mostly stand by whilst I try to make some sense of it. On Sat, Feb 23, 2008 at 1:11 PM, Benson Margulies <[EMAIL PROTECTED]> wrote: > I've reproduced this. > > On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > > > The CXF document says that Aegis data binding can even works on Map. I > > tried this, but it always return an empty one. Here's my testing codes. Did > > I miss something? Or I need to write special config file? > > > > > > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > > ParameterStyle.WRAPPED) > > public interface EmicroService { > > @WebMethod > > @RequestWrapper(className="test.model.Employee", > > localName="employee", targetNamespace=" > > http://test.emicro/types ") > > @Oneway > > public void addEmployee(Employee emp); > > > > > > @WebMethod(operationName="getEmployeesAsMap") > > @ResponseWrapper(className="java.util.HashMap", > > localName="EmployeesMap", targetNamespace=" > > http://test.emicro/types";) > > public Map getEmployeesMap(); > > > > } > > > > > > > > > > > > public static void main(String args[]) throws Exception { > > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > > > factory.setServiceClass(test.EmicroService.class); > > > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService > > "); > > > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > > > > > EmicroService client = (EmicroService)factory.create(); > > > > > > > >// add 2 employees here, then > > > > > > > >Map emap = client.getEmployeesMap(); > > > >logger.info(emap); > > > > > > > >System.exit(0); > > > >} > > > > > > > > The backend configuration is just following the CXF tutorial > > > > > > > > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > > > > > > address="/EmicroService"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > Any advice? Thanks > > > > > > >
Re: How to pass a HashMap
I've reproduced this. On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > The CXF document says that Aegis data binding can even works on Map. I > tried this, but it always return an empty one. Here's my testing codes. Did > I miss something? Or I need to write special config file? > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > ParameterStyle.WRAPPED) > public interface EmicroService { > @WebMethod > @RequestWrapper(className="test.model.Employee", > localName="employee", targetNamespace=" > http://test.emicro/types ") > @Oneway > public void addEmployee(Employee emp); > > > @WebMethod(operationName="getEmployeesAsMap") > @ResponseWrapper(className="java.util.HashMap", > localName="EmployeesMap", targetNamespace=" > http://test.emicro/types";) > public Map getEmployeesMap(); > > } > > > > > > public static void main(String args[]) throws Exception { > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > factory.setServiceClass(test.EmicroService.class); > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService";); > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > EmicroService client = (EmicroService)factory.create(); > > > >// add 2 employees here, then > > > >Map emap = client.getEmployeesMap(); > >logger.info(emap); > > > >System.exit(0); > >} > > > > The backend configuration is just following the CXF tutorial > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > address="/EmicroService"> > > > > > > > > > > > > > > Any advice? Thanks > > >
Re: How to pass a HashMap
What version of CXF have you got? On Fri, Feb 22, 2008 at 4:39 PM, Li, Weiye <[EMAIL PROTECTED]> wrote: > The CXF document says that Aegis data binding can even works on Map. I > tried this, but it always return an empty one. Here's my testing codes. Did > I miss something? Or I need to write special config file? > > > > > @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") > @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle= > ParameterStyle.WRAPPED) > public interface EmicroService { > @WebMethod > @RequestWrapper(className="test.model.Employee", > localName="employee", targetNamespace=" > http://test.emicro/types ") > @Oneway > public void addEmployee(Employee emp); > > > @WebMethod(operationName="getEmployeesAsMap") > @ResponseWrapper(className="java.util.HashMap", > localName="EmployeesMap", targetNamespace=" > http://test.emicro/types";) > public Map getEmployeesMap(); > > } > > > > > > public static void main(String args[]) throws Exception { > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > factory.setServiceClass(test.EmicroService.class); > > factory.setAddress("http://localhost:9080/emicro-ws/EmicroService";); > > factory.getServiceFactory().setDataBinding(new AegisDatabinding()); > > > > EmicroService client = (EmicroService)factory.create(); > > > >// add 2 employees here, then > > > >Map emap = client.getEmployeesMap(); > >logger.info(emap); > > > >System.exit(0); > >} > > > > The backend configuration is just following the CXF tutorial > > > > > >class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" > scope="prototype"> > > > > > > > > > > > > > > > > > > > > > > > > /> > > > > address="/EmicroService"> > > > > > > > > > > > > > > Any advice? Thanks > > >
How to pass a HashMap
The CXF document says that Aegis data binding can even works on Map. I tried this, but it always return an empty one. Here's my testing codes. Did I miss something? Or I need to write special config file? @WebService(name="EmicroManager", targetNamespace="http://test.emicro ") @SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED) public interface EmicroService { @WebMethod @RequestWrapper(className="test.model.Employee", localName="employee", targetNamespace=" http://test.emicro/types ") @Oneway public void addEmployee(Employee emp); @WebMethod(operationName="getEmployeesAsMap") @ResponseWrapper(className="java.util.HashMap", localName="EmployeesMap", targetNamespace="http://test.emicro/types";) public Map getEmployeesMap(); } public static void main(String args[]) throws Exception { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(test.EmicroService.class); factory.setAddress("http://localhost:9080/emicro-ws/EmicroService";); factory.getServiceFactory().setDataBinding(new AegisDatabinding()); EmicroService client = (EmicroService)factory.create(); // add 2 employees here, then Map emap = client.getEmployeesMap(); logger.info(emap); System.exit(0); } The backend configuration is just following the CXF tutorial Any advice? Thanks