# http-invoke **Repository Path**: wangGet/http-invoke ## Basic Information - **Project Name**: http-invoke - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2018-07-17 - **Last Updated**: 2022-12-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 内部service调用工具类 使用方法: http://项目域名/soa/spring.service名字/方法名?pwd=38bced94a36a4fede2ad28eeea5a87c0 例如: http://wms-out.man.7fresh.com/soa/spring.docMergeHeaderService/updateStatus?pwd=38bced94a36a4fede2ad28eeea5a87c0 使用postman进行调用,postman配置 1. 使用选用post请求 2. 选中`body`-->`raw` 3. 参数内容使用[]结尾 postman截图如下 ![输入图片说明](https://images.gitee.com/uploads/images/2019/0226/215139_8eec120d_383029.png "屏幕截图.png") ## 如何在项目中使用 1. 将本项目deploy到自己的maven私服 2. 需要使用的项目引入此包 3. 初始化SoaMonitorService ``` @Configuration public class SoaInvokeConfig { @Bean public SoaMonitorService soaMonitorService() { return new SoaMonitorServiceImpl(); } } ``` 4. 编写工具Controller ``` @Controller @RequestMapping("/soa") public class SoaMonitorAction { @Resource private SoaMonitorService soaMonitorService; @ResponseBody @RequestMapping(value = {"/{service}/{method}"}, method = {RequestMethod.GET, RequestMethod.POST},produces = "application/json;charset=UTF-8") public Object jsonQueryDeliveryCompany(@PathVariable("service") String service, @PathVariable("method") String method, @RequestBody String jsonData, String pwd) { try { return soaMonitorService.invokeServiceMethod(jsonData, service, method, null, pwd); } catch (Exception e) { return e.getMessage(); } } @ResponseBody @RequestMapping(value = {"/{service}/{method}/{methodId}"}, method = {RequestMethod.GET, RequestMethod.POST},produces = "application/json;charset=UTF-8") public Object jsonQueryDeliveryCompany(@PathVariable("service") String service, @PathVariable("method") String method, @PathVariable("methodId") Integer methodId, @RequestBody String jsonData, String pwd) { try { return soaMonitorService.invokeServiceMethod(jsonData, service, method, methodId, pwd); } catch (Exception e) { return e.getMessage(); } } } ``` ## 事例代码 * config https://gitee.com/wangGet/spring-boot-quick/blob/master/quick-weather/src/main/java/com/quick/config/SoaInvokeConfig.java * Controller https://gitee.com/wangGet/spring-boot-quick/blob/master/quick-weather/src/main/java/com/quick/api/SoaMonitorAction.java