| | |
| | | } finally { |
| | | |
| | | if(responseEntity == null){ |
| | | responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getString("msg"),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.OK); |
| | | responseEntity = new ResponseEntity<String>(dataFlow.getResJson().getJSONArray("msg").toJSONString(),OrderDataFlowContextFactory.hashMap2MultiValueMap(dataFlow.getResHeaders()),HttpStatus.OK); |
| | | } |
| | | if(dataFlow != null) { |
| | | //添加耗时 |
| | |
| | | */ |
| | | private void refreshOrderDataFlowResJson(IOrderDataFlowContext dataFlow){ |
| | | |
| | | if(dataFlow.getResJson() == null || dataFlow.getResJson().isEmpty()){ |
| | | JSONObject resJson = new JSONObject(); |
| | | resJson.put("msg","成功"); |
| | | dataFlow.setResJson(resJson); |
| | | } |
| | | // if(dataFlow.getResJson() == null || dataFlow.getResJson().isEmpty()){ |
| | | // JSONObject resJson = new JSONObject(); |
| | | // resJson.put("msg","成功"); |
| | | // dataFlow.setResJson(resJson); |
| | | // } |
| | | |
| | | } |
| | | |
| | |
| | | if(urls.length != 2){ |
| | | throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"配置错误:c_service_business配置url字段错误"+serviceBusiness.getBusinessTypeCd()); |
| | | } |
| | | String webserviceUrl = CodeMapUtil.getDynamicConstantValue(urls[0]); |
| | | String method = CodeMapUtil.getDynamicConstantValue(urls[1]); |
| | | String webserviceUrl = MappingCache.getValue(urls[0]); |
| | | String method = MappingCache.getValue(urls[1]); |
| | | responseMessage = (String) WebServiceAxisClient.callWebService(webserviceUrl,method, |
| | | new Object[]{requestBusinessJson.toJSONString()}, |
| | | serviceBusiness.getTimeout()); |
| | | }else if(ServiceBusinessConstant.INVOKE_TYPE_HTTP_POST.equals(serviceBusiness.getInvokeType())){ |
| | | //http://user-service/test/sayHello |
| | | String httpPostUrl = CodeMapUtil.getDynamicConstantValue(serviceBusiness.getUrl()); |
| | | String httpPostUrl = MappingCache.getValue(serviceBusiness.getUrl()); |
| | | responseMessage = restTemplate.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class); |
| | | }else if(ServiceBusinessConstant.INVOKE_TYPE_OUT_HTTP_POST.equals(serviceBusiness.getInvokeType())){ |
| | | String httpPostUrl = CodeMapUtil.getDynamicConstantValue(serviceBusiness.getUrl()); |
| | | String httpPostUrl = MappingCache.getValue(serviceBusiness.getUrl()); |
| | | responseMessage = restTemplateNoLoadBalanced.postForObject(httpPostUrl,requestBusinessJson.toJSONString(),String.class); |
| | | } |
| | | else {//post方式 |
| | | throw new ConfigDataException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"配置错误:c_service_business配置url字段错误,当前无法识别"+serviceBusiness.getBusinessTypeCd()); |
| | | } |
| | | |
| | | |
| | | logger.debug("订单服务调用下游服务请求报文:{},返回报文:{}",requestBusinessJson,responseMessage); |
| | | |
| | | if(StringUtil.isNullOrNone(responseMessage) || !Assert.isJsonObject(responseMessage)){ |
| | | throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR,"下游系统返回格式不正确,请按协议规范处理"); |
| | |
| | | JSONObject responseJson = doRequestBusinessSystem(dataFlow, serviceBusiness, requestBusinessJson); |
| | | |
| | | //发布事件 |
| | | DataFlowEventPublishing.invokeBusinessBSuccess(dataFlow,business); |
| | | DataFlowEventPublishing.invokeBusinessBSuccess(dataFlow,business,responseJson); |
| | | |
| | | responseBusinesses.add(responseJson); |
| | | |