Dear All,
I wrote a CXF web service that returns a hashmap. I wrote a marshaller
and demarshaller as well. Though I am able to invoke the method
sucessfuly, I could see the hashmap in my client side. And the error is
WARNING: Could not create accessor for property Entry of type
net.eads.ved.schema.manager.ResultMap
I hereby providing you the ResultMap class and ResultMapAdapter class
for your reference
public class ResultMapAdapter extends
XmlAdapter<ResultMap,Map<String,String>>{
@Override
public ResultMap marshal(Map<String, String> v) {
try{
return new ResultMap(v);
}
catch(Exception e){
System.out.println("marshal exception");
e.printStackTrace();
return null;
}
}
@Override
public Map<String, String> unmarshal(ResultMap v) {
try{
System.out.println("burrr unmarshal");
HashMap<String,String> map = new
HashMap<String,String>();
List<ResultMap.Entry> entries = v.getEntries();
for(int i = 0; i<entries.size();i++)
{
map.put(entries.get(i).getKey(),entries.get(i).getValue());
}
return map;
}
catch(Exception e){
System.out.println("unmarshal exception");
e.printStackTrace();
return null;
}
}
}
And
@XmlType(name = "ResultMap",propOrder = {"entry"})
@XmlAccessorType(XmlAccessType.FIELD)
public class ResultMap {
//protected List<ResultMap.Entry> entry;
private List<ResultMap.Entry> entry;
public ResultMap(){}
@SuppressWarnings("unchecked")
public ResultMap(Map<String,String> map){
entry = new ArrayList();
String temp = new String();
Iterator<String> i = map.keySet().iterator();
while(i.hasNext())
{
temp = i.next();
entry.add(new ResultMap.Entry(temp,map.get(temp)));
}
}
public List<ResultMap.Entry> getEntries() {
return entry;
}
protected static class Entry {
@XmlElement(name = "key", required = true)
//protected String key;
private String key;
@XmlElement(name = "value", required = true)
//protected String value;
private String value;
protected Entry(){}
protected Entry(String nkey, String nvalue) {
this.key = nkey;
this.value = nvalue;
}
protected String getKey() {
return key;
}
protected String getValue() {
return value;
}
}
}
Can anyone in the group tell me where I am doing wrong ?
Thanks in advance
Balachandar
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.