We've decided to just maintain a 'union' class that has get methods for all the possible items that can get into the map.
> -----Original Message----- > From: Daniel Kulp [mailto:[EMAIL PROTECTED] > Sent: Friday, August 24, 2007 1:11 PM > To: [email protected] > Cc: Benson Margulies > Subject: Re: choice versus map > > > With JAX-WS 2.0, I don't think theres a "clean" way to do this. You > could do something like: > > Object getAnnotation(String classOfAnnotation); > > and on the client side, provide a utility like: > > public T getAnnotation(Class<T> classOfAnnotation) { > return classOfAnnotation.cast( > service.getAnnotation(classOfAnnotation.getName()); > ); > } > > That kind of sucks though. With JAX-WS 2.1, you MIGHT be able to use > the @XmlJavaTypeAdapter annotation on the Class parameter to map it to a > String in the wsdl to do much of that automatically. To do that with > 2.0 would require you to use wrapped doc/lit and to write > a "GetAnnotationRequest" class that hadd the @XmlJavaTypeAdapter on > the "classOfAnnotation" property. > > > The other issue you will run into is getting all the possible types of > <T> into the JAXB contexts so that they can be marshalled. The > jaxb.index files can come in there as well as the spring configurations > for the JAXB databindings and such. > > > Dan > > > On Tuesday 21 August 2007, Benson Margulies wrote: > > We've got an API that associates from a class to an object of the > > class. It's not unlike some of the insides of CXF in this regard. It > > depends on generics. > > > > > > > > T getAnnotation(Class<T> classOfAnnotation) > > > > > > > > We're trying to export this as a web service via CXF. > > > > > > > > Mediocre alternative #1: > > > > > > > > Use the @XmlElement annotation that specifies a choice for the > > XSD, and simply return a Set<Object> marked up as a set of the limited > > set of possible classes noted in the @XmlElement. > > > > > > > > This is not so hot, as the caller now has to crawl around in the Set > > or List or whatever to find the item of the desired class. > > > > > > > > We were hoping to cook up a way to express > > > > > > > > Map<String, Object>, and provide the class names as the keys. We > > can't figure out the @XmlElement magic that would support this, if > > any. Any JAX-WS experts out there with a clue, or the word that there > > is no hope? > > > > -- > J. Daniel Kulp > Principal Engineer > IONA > P: 781-902-8727 C: 508-380-7194 > [EMAIL PROTECTED] > http://www.dankulp.com/blog
