针对多个XML请求 .
json序列化包:com.alibaba.fastjso
public JSONObject XMLRequest(String methodName, String url, String paramsss) throws JsonProcessingException { RestTemplate restTemplate = new RestTemplate(); String xmlInfo = getXmlInfo(methodName, paramsss); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_XML); HttpEntity entity = new HttpEntity(xmlInfo, headers); ResponseEntity
private String getXmlInfo(String methodName, String params) { StringBuilder sb = new StringBuilder(); sb.append("<?xml version='1.0' encoding='UTF-8'?>"); sb.append("
public String subString(String str, String strStart, String strEnd) { int strStartIndex = str.indexOf(strStart); int strEndIndex = str.indexOf(strEnd); if (strStartIndex < 0) { return "字符串 :---->" + str + "<---- 中不存在 " + strStart + ", 无法截取目标字符串"; } if (strEndIndex < 0) { return "字符串 :---->" + str + "<---- 中不存在 " + strEnd + ", 无法截取目标字符串"; } String result = str.substring(strStartIndex, strEndIndex).substring(strStart.length()); return result; }
eg:`
public String LYHLogin() throws JsonProcessingException { String url = "http://121.89.178.60/WebServices/UserAdminService.asmx"; String paramsss = "