数据传输格式报文格式:xmlpublic CisReportRoot queryCisReport(PyQueryBean pyQueryBean) throwsException {
CisReportRoot cisReportRoot=invokePy(pyQueryBean){
CisReportRoot cisReportRoot=queryCisReportFromPyServer(pyQueryBean); } }
pyQueryBean--CisReportRoot
注意:接口数据传输通过xml,无论发送请求,还是获取响应都需要经过经过xml格式转化。1,CisReportRoot cisReportRoot = getCisReportRoot(doc); pyQueryBean--Map--doc--xmL
//实体转化为Map
2,Map map = CommonUtils.beanToMap(pyQueryBean);
//Map转化为指定标签的xml字符串 Map-doc-xml
3,String queryInfo = XmlUtil.createQueryCondition(map);
//从鹏元获取Xml,转化为doc xml-doc-
4,Document doc =pyClient.connectToPyClient(queryInfo);
//解析doc中数据,赋值到实体
5,CisReportRoot cisReportRoot = getCisReportRoot(doc);
具体实现如下:2,public static MapbeanToMap(Object obj) {if (obj == null) {return null;
}
Map map = new HashMap<>();try{
BeanInfo beanInfo=Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors();for(PropertyDescriptor property : propertyDescriptors) {
String key=property.getName();//过滤class属性
if (!"class".equals(ke