-
1. Re: return/pass JavaBean ?
burrsutter May 23, 2006 8:40 AM (in response to ericmacau)I'm working on an example for my own purposes. Perhaps we can work together...
I'm working on the Service side for now here is my attempt at returning a JavaBean/POJO as well as a List/collection of those POJOs
Note: this isn't currently working but might help us move in the same direction:@WebService(name = "POJOService", targetNamespace="http://com.burrsutter.jbossws/pojoservice")@SOAPBinding(style = SOAPBinding.Style.RPC) public class POJOService { @WebMethod(operationName="GetPersonByID") public Person getPerson(String id) { System.out.println("Looking for " + id); Person somebody = new Person(); somebody.setName("Burr Sutter"); somebody.setAge(24); somebody.setBirthDate(new java.util.Date()); return somebody; } @WebMethod (operationName="GetAllPeople") public List<Person> getPeople() { List<Person> results = new ArrayList<Person>(); Person a = new Person(); a.setName("Burr Sutter"); a.setAge(24); a.setBirthDate(new java.util.Date()); results.add(a); Person b = new Person(); b.setName("Thomas Diesler"); b.setAge(23); b.setBirthDate(new java.util.Date()); results.add(b); return results; } }
What do you think?
Burr
burr.sutter@jboss.com -
2. Re: return/pass JavaBean ?
burrsutter May 23, 2006 12:56 PM (in response to ericmacau)As a follow up to my own post, returning a collection like a List doesn't work and based on my reading of the specification, I'm not sure that it is supposed to. So here is an example that returns an array of POJOs:
@WebMethod (operationName="GetAllPeopleArray") public Person[] getPeople2() { Person[] results = new Person[2]; Person a = new Person(); a.setName("Burr Sutter"); a.setAge(24); a.setBirthDate(new java.util.Date()); results[0] = a; Person b = new Person(); b.setName("Thomas Diesler"); b.setAge(23); b.setBirthDate(new java.util.Date()); results[1] = b; return results; }
This works fine with a VB.NET consumer. The previous example returing a List did compile but the WSDL wasn't useful. In .NET Web Services returing a List collection does work and seems to kick out an array from the perspective of the WSDL.
Burr
burr.sutter@jboss.com -
3. Re: return/pass JavaBean ?
ramcisjboss May 23, 2006 7:08 PM (in response to ericmacau)Yes, you can pass a java bean as a parameter.
-
4. Re: return/pass JavaBean ?
ekhosid May 25, 2006 10:48 AM (in response to ericmacau)How do you annotate the bean class so it shows up in WSDL file correctly?
-
5. Re: return/pass JavaBean ?
ekhosid May 25, 2006 11:36 AM (in response to ericmacau)Never mind my question.
-
6. Re: return/pass JavaBean ?
thomas.diesler May 29, 2006 5:57 AM (in response to ericmacau)ekhosid,
your question is valid and part of the JAXWS + JAXB functionality. Currently, we are working on this part and you will be able to use annotaed user types in one of the next versions.