tuscany-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Kurz <sku...@gmail.com>
Subject Re: Generated WSDL lose object info when return type is List<HashMap>> or Map<ArrayList>>
Date Sun, 30 Dec 2012 00:08:17 GMT
Hi Nguyen,

Tuscany is using JAXB as the databinding to map from Java to WSDL/XSD,
and you've got a couple dimensions of complexity here...

For one you're trying to use a generic 'java.lang.Object' type, and
you're also using Map(s) which don't have an obvious mapping to XSD.

I'd suggest researching the topic of JAXB's @XmlAdapter, which allows
you to add your own custom marshalling/unmarshalling logic to some
code like the Tuscany runtime's binding.ws which uses JAXB as a
databinding.

Just searching I hit on these articles, and there is the Javadoc as well:

http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret-weapon.html
http://javaevangelist.blogspot.com/2011/12/java-tip-of-day-generic-jaxb-map-v.html

The @XmlAdapter will definitely help you deal with the Map(s)... the
way you might deal with java.lang.Object as the parameter type might
depend on how much you know about the types that will be used (e.g. is
it a few well known types but without a common superclass or are you
trying to accept an indefinite set of types?).

In taking this route, you might find it helpful to try to do some
"meet in the middle" thinking... e.g. try to figure out what the XML
would look like, define a schema, and then use @XmlAdapter to adapt
this to your Java interface.

Hope that helps,
Scott




On Thu, Dec 6, 2012 at 5:12 AM, makiet <Binhnt22@viettel.com.vn> wrote:
> Hi,
>
>
>
> I have an interface with some functions return List<HashMap<String, Object>>
> and Map<ArrayList<Object>>
>
>
>
> When I make the interface exposed as a service with binding.ws, the
> generated wsdl contains a complex type HashMap or ArrayList without content
>
>
>
> Ie: <xs:complexType name="hashMap">
>
>                 <xs:complexContent>
>
>                                 <xs:extension base="tns:abstractMap">
>
>                                                 <xs:sequence>
>
>                                                 </xs:sequence>
>
>                                 </xs:extension>
>
>                 </xs:complexContent>
>
> </xs:complexType>
>
> <xs:complexType abstract="true" name="abstractMap">
>
> <xs:sequence>
>
>
>
> Therefore, I have no way to get the expected result. May anyone help me out?
>
>
>
> Best regards,
>
> ------------------------------------------------------------------
>
> Binh, Nguyen Thanh
>
> Software Architecture
>
> Product Department - BU BSS, Software Center, Viettel Group
>
>

Mime
View raw message