import org.apache.commons.lang3.StringEscapeUtils;   //依赖的包


StringBuilder content = new StringBuilder();
content.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
content.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.interfacemodule.lbcs.midea.com\">");
content.append("<soapenv:Header/>");
content.append("<soapenv:Body>");
content.append("<ser:doCheckQrcode>");
content.append("<ser:inParams><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
content.append("<input><qrcode>").append(params.get("qrcode")).append("</qrcode>")
.append("<checkCode>").append(params.get("checkCode")).append("</checkCode></input>]]></ser:inParams>");
content.append("</ser:doCheckQrcode>").append("</soapenv:Body>").append("</soapenv:Envelope>");

System.out.println(content.toString());

HttpClientUtil httpClient = (HttpClientUtil) ContextUtils.getBean("httpClient");
String result = "";
Output output = null;
try {
result = httpClient.postSoap(LbcsURL, content.toString(), "doCheckQrcode");
if(StringUtil.isPresent(result)){
String xml = StringEscapeUtils.unescapeHtml4(result); //转义操作

xml = xml.substring(xml.indexOf("<ns:return>")+"<ns:return>".length(),xml.indexOf("</ns:return>"));
JAXBContext context = JAXBContext.newInstance(Output.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
output = (Output)unmarshaller.unmarshal(new StringReader(xml));
}
} catch (Exception e) {
e.printStackTrace();
}

return JSONObject.parseObject(output.toString());

相关文章:

  • 2022-01-07
  • 2021-12-28
  • 2021-04-14
  • 2021-05-25
  • 2022-12-23
  • 2021-04-09
  • 2022-01-12
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-05-23
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案