资源数据转发

This commit is contained in:
huangweixiong 2022-05-24 15:29:25 +08:00
parent 56cc7cfbf4
commit f6e52a5c59
1 changed files with 26 additions and 0 deletions
renren-admin/src/main/java/io/renren/modules/resource/controller

View File

@ -17,9 +17,12 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
@ -36,6 +39,9 @@ public class ResourceController {
@Autowired @Autowired
private ResourceService resourceService; private ResourceService resourceService;
@Autowired
private RestTemplate restTemplate;
private static Logger logger = LoggerFactory.getLogger(ResourceController.class); private static Logger logger = LoggerFactory.getLogger(ResourceController.class);
@GetMapping("/page") @GetMapping("/page")
@ -162,6 +168,26 @@ public class ResourceController {
return new Result(); return new Result();
} }
@GetMapping("ZywMessage")
public Result ZywMessage(){
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx";
String parame = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body>\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("SOAPAction", "http://tempuri.org/ZywMessagePort");
requestHeaders.setContentType(MediaType.TEXT_XML);
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
String body = restTemplate.postForEntity(url,requestEntity,String.class).getBody();
String json = body.substring(body.indexOf("{"), body.indexOf("}") + 1);
HashMap map = JSONObject.parseObject(json, HashMap.class);
return new Result().ok(map);
}
/* /*
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")