第一点:list
所以要这样list
上代码:第一步建立适配器,不要问怎么弄的,百度学的
package com.ailk.esb.work;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class MapAdapter extends XmlAdapter> {
@Override
public MapConvertor marshal(Map map) throws Exception {
MapConvertor convertor = new MapConvertor();
for(Map.Entry entry:map.entrySet()){
MapConvertor.MapEntry e = new MapConvertor.MapEntry(entry);
convertor.addEntry(e);
}
return convertor;
}
@Override
public Map unmarshal(MapConvertor map) throws Exception {
Map result = new HashMap();
for(MapConvertor.MapEntry e :map.getEntries()){
result.put(e.getKey(), e.getValue());
}
return result;
}
}
package com.ailk.esb.work;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
@XmlType(name = "MapConvertor")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
//@XmlSeeAlso({User.class})//如果传递的是List
第二步:我自己实现了hashmap 命名问IMap,方法都一样,也可以直接是hashmap
然后写出接口:只看test方法哦,getreporteoms是javabean的
package com.ailk.esb.work.service;
import java.util.List;
import javax.jws.WebService;
import com.ailk.esb.work.mode.ReportBean;
import com.ailk.utils.IMap;
@WebService(name = "IEomReportESBSrv", targetNamespace = "http://ailk.eom.com")
public interface EomReportESBSrv {
/**
* 获取实时查询集合
*
* @param @WebParam(name = "param")
*/
//@WebParam(name = "index") int index
public List getReportEoms(String areaName,String timeInterval);
List test(String areaName, String timeInterval);
}
package com.ailk.esb.work.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.log4j.Logger;
import com.ailk.esb.work.MapAdapter;
import com.ailk.esb.work.dao.PimReportMapper;
import com.ailk.esb.work.mode.ReportBean;
import com.ailk.esb.work.service.EomReportESBSrv;
import com.ailk.om.dao.PimWorkInstMapper;
import com.ailk.utils.IMap;
/**
*
* @param portName wsdl文档:默认是"类名+ServicePort"
* @param serviceName wsdl文档:
* @param targetNamespace 命名空间,对应tns的定义.默认是“http://”+包(package)反过来写
* @param endpointInterface 要暴露的接口类。指定Interface全名,包括包名
*
* @author Yuang
*/
@WebService(serviceName = "IEomReportESBSrv", portName = "IEomReprotESBSrvPort",
endpointInterface = "com.ailk.esb.work.service.EomReportESBSrv",targetNamespace="http://ailk.eom.com")
/* 地市 是 入参 全省默认为80223
时间间隔(秒) 是 入参 系统时间-时间间隔
网元ID 出参 出参为集合
影响设备ID 出参
网元类型 出参
工单状态 未完工|已完工 出参
工单号 出参 */
public class EomReportESBSrvImpl implements EomReportESBSrv {
@Resource
private PimWorkInstMapper pimWorkInstMapper;
@Resource
private PimReportMapper pimReportMapper;
private Logger logger = Logger.getLogger(this.getClass());
@Override
public List getReportEoms(String areaName, String timeInterval) {
logger.fatal("报表初始化接口areaName:"+areaName+"-------timeInterval:"+timeInterval);
String message = "";
//List list = new ArrayList();
List list = new ArrayList();
IMap map = new IMap();
if(areaName != null && timeInterval != null){
long time = (new Date()).getTime();
Date preTime = new Date(time-Long.parseLong(timeInterval));
areaName = areaName.equals("80223") ? "" : areaName ;
map.put("endTime", new Date());
map.put("startTime", preTime);
map.put("areaName", areaName);
//list = pimWorkInstMapper.getReportDataList(map);
list = pimReportMapper.getReportDataList(map);
}else{
message = "传入值为空";
}
map.put("message",message);
//list.add(map);
return list;
}
@Override
@XmlJavaTypeAdapter(MapAdapter.class)
public List test(String areaName, String timeInterval) {
logger.fatal("报表初始化接口areaName:"+areaName+"-------timeInterval:"+timeInterval);
String message = "";
List list = new ArrayList();
//List list = new ArrayList();
IMap map = new IMap();
if(areaName != null && timeInterval != null){
long time = (new Date()).getTime();
Date preTime = new Date(time-Long.parseLong(timeInterval));
areaName = areaName.equals("80223") ? "" : areaName ;
map.put("endTime", new Date());
map.put("startTime", preTime);
map.put("areaName", areaName);
list = pimWorkInstMapper.getReportDataList(map);
//list = pimReportMapper.getReportDataList(map);
}else{
message = "传入值为空";
}
map.put("message",message);
//list.add(map);
return list;
}
}
好了,我们成功了!
客户端测试代码:
public static void main(String[] args) {
// TODO Auto-generated method stub
IEomReportESBSrv_Service service = new IEomReportESBSrv_Service();
IEomReportESBSrv servicePort = service.getIEomReprotESBSrvPort();
System.out.println(servicePort);
List list = servicePort.test("80340", "1472471343922");
System.out.println(list.size());}
JAX-WS RI 2.2.4-b01: Stub for http://localhost:8080/eom/esb/reportWork
com.eom.ailk.IMap@2fe2622b