Tnanks for the reply Daniel,
Yes, I was successful with that java first approach. But I am more
interested in Glen Mazza's tutorial in which a contract first approaach
was described. In that approach,
I wanted to return an hashmap. Hence, I wrote the wsdl first, generated
bindings and modified the service interface to return hashmap. This is
becoz, the generated binding;s interface returns ResultMap, that is, a
'List<object>' {where object contains the key and value}. Hence, in
order to convert List<object> to hashmap and vice versa I wrote the
ResultMapAdapter class.
Here, I am facing a problem. I did follow your suggestion but I am
facing the error, that "ResultMap cannot be cast to HashMap" accompanied
by a warning that "Cannot create accessor type Entry" {where Entry is
the inner class in ResultMap that wraps the 'key' and 'value'}
With thanks and regards
Balachandar
-----Original Message-----
From: Daniel Kulp [mailto:[email protected]]
Sent: 20 April 2010 20:45
To: [email protected]
Cc: AMARNATH, Balachandar
Subject: Re: hashMap binding
On Tuesday 20 April 2010 12:22:18 am balson1980 wrote:
> I was struggling to return a hashmap from a cxf based web service and
> I came across your tutorial. I tried the same way, but still could not
> suceed in that.I have presented my issue below. If found time, pls
> have a look at this and suggest me :)
You could also look at the java_first_jaxws sample in the CXF
distribution.
It returns a Map for something.
> I could deploy this service onto container and see its publishing but
> when I invoke the method through a client, an erros comes in the
> container saying, java.util.HashMap cannot be casted to
> java.util.List. I am struggling here for the past few days and could
not come to a solution.
> For your reference I have also given my ResultMap class
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "resultMap", propOrder = {
> "entry"
> })
> public class ResultMap {
> @XmlJavaTypeAdapter(ResultMapAdapter.class);
I think this annotation is in the wrong place. I THINK this would
need to
go on the
public HashMap<String,String> launchVMs(...) method as it's the Adapter
for that HashMap.
Dan
> protected List<ResultMap.Entry> entries;
>
>
> public ResultMap(){} // empty constructor
>
> public List<ResultMap.Entry> getEntry() {
> if (entries == null) {
> entries = new ArrayList<ResultMap.Entry>();
> }
> return this.entries;
> }
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {
> "key",
> "value"
> })
> public static class Entry {
>
> @XmlElement(required = true)
> protected String key;
> @XmlElement(required = true)
> protected String value;
>
> /**
> * Gets the value of the key property.
> *
> * @return
> * possible object is
> * {...@link String }
> *
> */
> public String getKey() {
> return key;
> }
> public void setKey(String value) {
> this.key = value;
> }
> public String getValue() {
> return value;
> }
>
> public void setValue(String value) {
> this.value = value;
> }
>
> }
>
>
> }
>
>
> Can you figure out from these input where I am doing wrong ? Thanks a
> lot,
>
>
> With regards
> Balachandar
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
This mail has originated outside your organization, either from an
external partner or the Global Internet.
Keep this in mind if you answer this message.
The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this e-mail by
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of
this e-mail as it has been sent over public networks. If you have any concerns
over the content of this message or its Accuracy or Integrity, please contact
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus
scanning software but you should take whatever measures you deem to be
appropriate to ensure that this message and any attachments are virus free.