3 Replies Latest reply on Feb 9, 2005 1:12 PM by Jason Greene

    Collections as return types

    Tim McCune Novice

      I have an EJB that I'm working on exposing as a web service. One of my methods returns Collection, where CustomType is a POJO JavaBean. When I run this through wscompile, it complains:

      Collection types are not supported in literal mode - Type: "java.util.Collection"

      I'll admit I'm a newbie to web services, so I don't get why this is a problem. I've been searching the web and these forums for a while and I'm still kind of puzzled. So my first question is, why aren't collection types supported, and what should I use instead?

      Next I tried modifying my method signature to return an array (e.g. CustomType[]). This made it through wscompile with no problem, but when I deployed my ear, I got the following warning:
      Cannot find jaxrpc-mapping for type: {http://hmsonline.com/arrays/com/hmsonline}CustomTypeArray

      and when I tried to invoke my web service, JBoss threw an IOException:
      java.io.IOException: No serializer found for class com.hmsonline.CustomType in registry org.apache.axis.encoding.TypeMappingImpl@57b746

      even though my wsdl file has a definition, and if I modify the method signature to return CustomType instead of CustomType[], it works fine.

      I downloaded samples.zip from the Wiki and looked at the complexbean example. It looks like in that case, the author has created some contrived CustomerArray class that just wraps an array of Customers. Do I need to something like this? If so, why? It seems ridiculous to write a custom class just to wrap an array. Am I missing something obvious? What's the problem with returning Collections? I would really appreciate any pointers. Thanks.

      --Tim