|
@ -87,15 +87,7 @@ public class MqSdkUtil {
|
|
|
msgId = queueTools.putMsg(queueManager, xmlNodeName, json2xml(reqMsg,xmlNodeName,"JKZL","123456","S60","S01",stringList));
|
|
|
// 获取响应消息
|
|
|
respMsg = queueTools.getMsgById(queueManager, xmlNodeName, msgId, 3);
|
|
|
if (StringUtils.isNotBlank(respMsg)) {
|
|
|
if ("1".equals(parsingWay)) {
|
|
|
respMsg = xml2jsonObject(respMsg);
|
|
|
} else {
|
|
|
respMsg = xml2jsonArray(respMsg);
|
|
|
}
|
|
|
}
|
|
|
// 此处为获取响应数据后的业务处理
|
|
|
log.info("respMsg==" + respMsg);
|
|
|
// log.info("respMsg==" + respMsg);
|
|
|
return respMsg;
|
|
|
} catch (MQException e) {
|
|
|
// 2033表示队列中没有消息
|
|
@ -136,6 +128,7 @@ public class MqSdkUtil {
|
|
|
//是否展示类型
|
|
|
xmlSerializer.setObjectName("ESBEntry");
|
|
|
xmlSerializer.setTypeHintsEnabled(false);
|
|
|
xmlSerializer.setSkipNamespaces(true);
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
JSONObject accessControl=new JSONObject();
|
|
|
accessControl.put("Fid",fid);
|
|
@ -154,8 +147,12 @@ public class MqSdkUtil {
|
|
|
//{"Fid":"BS15017","Password":[],"UserName":[]},"MessageHeader":{"Fid":"BS15017","MsgDate":"2018-11-21 13:20:40","SourceSysCode":"S60","TargetSysCode":"S01"},"MsgInfo":{"endNum":"20000","Msg":[],"query":{"@compy":"=","@item":"CARD_NO","@splice":"and","@value":"D26818411"},"startNum":"1"}}
|
|
|
String root="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
|
|
|
String xmlString=xmlSerializer.write(jsonObject);
|
|
|
for (String str:stringList){
|
|
|
xmlString=xmlString.replace(str,"'"+str+"'");
|
|
|
try {
|
|
|
for (String str:stringList){
|
|
|
xmlString=xmlString.replace(str+"","'"+str+"'");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return xmlString.replace(root,"");
|
|
|
}
|
|
@ -189,6 +186,32 @@ public class MqSdkUtil {
|
|
|
return getMsgInfo(json);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将xml字符串<STRONG>转换</STRONG>为JSON字符串,msg的根节点为row
|
|
|
* XML中Msg为数组
|
|
|
*
|
|
|
* @param xmlString xml字符串
|
|
|
* @return JSON<STRONG>对象</STRONG>
|
|
|
*/
|
|
|
public static String xml2jsonArrayRootRow(String xmlString) throws Exception {
|
|
|
XMLSerializer xmlSerializer = new XMLSerializer();
|
|
|
JSON json = xmlSerializer.read(xmlString);
|
|
|
Object jsonObject = ((net.sf.json.JSONObject) json).get("MsgInfo");
|
|
|
if (null != jsonObject) {
|
|
|
net.sf.json.JSONObject jsonObject1 = (net.sf.json.JSONObject) jsonObject;
|
|
|
//获取到数组中的CDATA进行再解析
|
|
|
net.sf.json.JSONArray jsonArray = (net.sf.json.JSONArray) jsonObject1.get("Msg");
|
|
|
net.sf.json.JSONArray jsonArray1 = new net.sf.json.JSONArray();
|
|
|
for (Object object : jsonArray) {
|
|
|
JSON jsonsub = xmlSerializer.read(object.toString());
|
|
|
jsonArray1.add(jsonsub);
|
|
|
}
|
|
|
//重新封装到json中
|
|
|
((net.sf.json.JSONObject) json).element("MsgInfo", jsonArray1);
|
|
|
}
|
|
|
return getMsgInfo(json);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将xml字符串<STRONG>转换</STRONG>为JSON字符串
|
|
|
* 其中Msg为一个对象
|