| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.swing.border.Border; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.io.*; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | public class ReceivingServices { |
| | |
| | | } |
| | | |
| | | // 设置请求头部,否则可能会报 “no SOAPAction header” 的错误 |
| | | postMethod.setRequestHeader("SOAPAction", ""); |
| | | postMethod.setRequestHeader("SOAPAction", "application/x-www-form-urlencoded; charset=UTF-8"); |
| | | // 设置请求体 |
| | | postMethod.setRequestEntity(requestEntity); |
| | | int status = 0; |
| | |
| | | } |
| | | if (status == 200) {// 成功 |
| | | InputStream is = null; |
| | | try { |
| | | is = postMethod.getResponseBodyAsStream(); |
| | | } catch (IOException e) { |
| | | logger.info("errorLocation2,"+e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | // 获取请求结果字符串 |
| | | String result = null; |
| | | try { |
| | | result = IOUtils.toString(is); |
| | | result = postMethod.getResponseBodyAsString(); |
| | | logger.info("二次输出流333333,{}",result); |
| | | return result; |
| | | } catch (IOException e) { |
| | | logger.info("errorLocation3,"+e); |
| | | logger.info("errorLocation2,"+e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | |
| | | if (ObjectUtil.isNotNull(result)){ |
| | | logger.info("messageLocation2,"+result); |
| | | String string = result.get("EV_MESSAGE").toString(); |
| | | if (string.contains("查询成功")){ |
| | | logger.info("messageLocation3,"+string); |
| | | JsonObject etData = jsonObject2 |
| | | .getAsJsonObject("SOAP:Envelope") |
| | | .getAsJsonObject("SOAP:Body") |
| | | .getAsJsonObject("n0:ZPP_CF_MES_005.Response") |
| | | .getAsJsonObject("ET_DATA"); |
| | | data = etData.toString(); |
| | | logger.info("messageLocation4,"+data); |
| | | } |
| | | // if (string.contains("查询成功")){ |
| | | // logger.info("messageLocation3,"+string); |
| | | // JsonObject etData = jsonObject2 |
| | | // .getAsJsonObject("SOAP:Envelope") |
| | | // .getAsJsonObject("SOAP:Body") |
| | | // .getAsJsonObject("n0:ZPP_CF_MES_005.Response") |
| | | // .getAsJsonObject("ET_DATA"); |
| | | // data = etData.toString(); |
| | | // logger.info("messageLocation4,"+data); |
| | | // } |
| | | logger.info("messageLocation3,"+string); |
| | | JsonObject etData = jsonObject2 |
| | | .getAsJsonObject("SOAP:Envelope") |
| | | .getAsJsonObject("SOAP:Body") |
| | | .getAsJsonObject("n0:ZPP_CF_MES_005.Response") |
| | | .getAsJsonObject("ET_DATA"); |
| | | data = etData.toString(); |
| | | logger.info("messageLocation4,"+data); |
| | | } |
| | | |
| | | return data; |