@XmlRootElement(name = "InitiatePhoneCall", namespace = "namespace")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InitiatePhoneCall",
namespace = "namespace",
propOrder = {"messageParams"})
public class InitiatePhoneCall implements IRequest {
// variables
@XmlElement(name = "MessageParams", namespace = "namespace")
private HashMap<String, Object> messageParams;
public HashMap<String, Object> getMessageParams() {
return messageParams;
}
public void setMessageParams(HashMap<String, Object> messageParams) {
this.messageParams = messageParams;
}
//getter setters
}
我在我的应用程序中有上面的代码块。我正在使用带有JDK 1.7的Weblogic 12c服务器。我在Web服务部署中得到了这个:
javax.xml.ws.WebServiceException:class package.InitiatePhoneCall在com.sun.xml.ws.server.sei.EndpointArgumentsBuilder $ DocLit中没有名称{namespace} MessageParams的属性。(EndpointArgumen tsBuilder.java :610)com.sun.xml.ws.server.sei.TieHandler.createArgumentsBuilder(TieHandler.java:143)at com.sun.xml.ws.server.sei.TieHandler。(TieHandler.java:115)at com .sun.xml.ws.db.DatabindingImpl。(DatabindingImpl.java:116)
答案 0 :(得分:0)
1#解决方案
使用此InitiatePhoneCall
类
@XmlRootElement(name = "InitiatePhoneCall", namespace = "namespace")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InitiatePhoneCall",
namespace = "namespace",
propOrder = {"messageParams"})
public class InitiatePhoneCall implements IRequest {
@XmlElementWrapper(name="MessageParams",namespace="namespace")
private HashMap<String, Object> messageParams = new HashMap<String, Object>();
public HashMap<String, Object> getMessageParams() {
return messageParams;
}
public void setMessageParams(HashMap<String, Object> messageParams) {
this.messageParams = messageParams;
}
}
2#解决方案
您还可以使用@XmlAdapter
import java.util.*;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class MapAdapter extends XmlAdapter<MapAdapter.AdaptedMap, Map<String, Object>> {
public static class AdaptedMap {
public List<Entry> entry = new ArrayList<Entry>();
}
public static class Entry {
public String key;
public Object value;
}
@Override
public Map<String, Object> unmarshal(AdaptedMap adaptedMap) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
for(Entry entry : adaptedMap.entry) {
map.put(entry.key, entry.value);
}
return map;
}
@Override
public AdaptedMap marshal(Map<String, Object> map) throws Exception {
AdaptedMap adaptedMap = new AdaptedMap();
for(Map.Entry<String, Object> mapEntry : map.entrySet()) {
Entry entry = new Entry();
entry.key = mapEntry.getKey();
entry.value = mapEntry.getValue();
adaptedMap.entry.add(entry);
}
return adaptedMap;
}
}
InitiatePhoneCall
上课
@XmlRootElement(name = "InitiatePhoneCall", namespace = "namespace")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InitiatePhoneCall",
namespace = "namespace",
propOrder = {"messageParams"})
public class InitiatePhoneCall implements IRequest {
@XmlElement(name="MessageParams",namespace="namespace")
@XmlJavaTypeAdapter(MapAdapter.class)
private HashMap<String, Object> messageParams = new HashMap<String, Object>();
public HashMap<String, Object> getMessageParams() {
return messageParams;
}
public void setMessageParams(HashMap<String, Object> messageParams) {
this.messageParams = messageParams;
}
}