在java中使用SOAP返回HashMap
我曾担任过两次手术的同仁在java中使用SOAP返回HashMap,java,soap,wsdl,Java,Soap,Wsdl,我曾担任过两次手术的同仁 @WebService(serviceName = "NewWebService") public class NewWebService { /** * This is a sample web service operation * @param txt * @return */ @WebMethod(operationName = "GetAvailableOptions") public L
@WebService(serviceName = "NewWebService")
public class NewWebService {
/**
* This is a sample web service operation
* @param txt
* @return
*/
@WebMethod(operationName = "GetAvailableOptions")
public List<String> GetAvailableOptions(@WebParam(name = "name") String txt ) {
newpackage.StringArray arr = new newpackage.StringArray();
List<String> listopt = arr.getList();
endicia.MainStarter main = new endicia.MainStarter();
main.renderMsg(txt);
listopt = main.getOpt();
listopt = main.getOpt();
return listopt;
}
/**
* This is a sample web service operation
* @param type
* @param nMap
* @return
*/
@WebMethod(operationName = "GetLabel")
public HashMap<String,String> GetLabel(@WebParam(name = "name") String type,@WebParam(name = "values")HashMap<String,String> nMap) {
String categoryName = type;
HashMapWrapper getLabel = new HashMapWrapper();
HashMap<String,String> response = getLabel.getMap();
endicia.MainStarter main = new endicia.MainStarter();
main.renderMsg(categoryName, nMap);
response = main.getHashMap();
return response ;
}
}
但当我评论返回hashmap并点击URL增益的第二个操作时,它的工作正常
现在我认为问题在于返回hashmaps
任何人都知道如何解决这个问题
下面是我的包装类
public class HashMapWrapper {
private HashMap<String, String> nMap;
public HashMapWrapper() {
this.nMap = new HashMap<String,String>();
}
public HashMap<String,String> getMap(){
return this.nMap;
}
}
我正在将glassfish-4.0与netbeans 8.0配合使用。它更可能是一个名为“值”的映射的参数。@DanTemple能否请您对这一点进行详细说明。我一整天都在关注这个问题,我不确定,但我猜您的问题可能与您希望第二个服务能够接受HashMap作为其参数之一有关。通常,当您有这样复杂的数据类型时,可能会通过JAXB或类似的方式将soapxml请求映射到请求的特定对象。我不确定您的SOAP请求如何能够仅仅表示一个原始HashMap,以及您的服务如何能够在两者之间进行转换。
public class HashMapWrapper {
private HashMap<String, String> nMap;
public HashMapWrapper() {
this.nMap = new HashMap<String,String>();
}
public HashMap<String,String> getMap(){
return this.nMap;
}
}