سؤال

I do know that the hashmap data structure is not allowed in JAX-RPC webservice.

But i would like to return data which looks like this in my service.

Atrribute,<Key><value>,Atrribute,<Key><value>,Atrribute,<Key><value> ..

Any idea how would i do this please

هل كانت مفيدة؟

المحلول

TO Return Map like structue you need to wrap it in Wrapper class.

Wrap your Map into JAXBMap as shown below and return it.

package myexample;

import java.util.Map;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class JAXBMap<T, K> {
Map<T, K> map;

public Map<T, K> getMap() {
    return map;
}

public void setMap(Map<T, K> map) {
    this.map = map;
}

public JAXBMap(Map<T, K> map) {
    super();
    this.map = map;
}

public JAXBMap() {
    super();
}

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top