diff --git a/pom.xml b/pom.xml index e0e9836..20bf181 100644 --- a/pom.xml +++ b/pom.xml @@ -89,34 +89,51 @@ 4.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - org.apache.axis - axis - 1.4 - - - - org.apache.axis - axis-jaxrpc - 1.4 - - - - commons-discovery - commons-discovery - 0.2 + org.apache.cxf + cxf-rt-transports-http + 3.1.8 - - commons-logging - commons-logging - 1.1.1 + org.apache.cxf + cxf-rt-frontend-jaxws + 3.1.8 - - wsdl4j - wsdl4j - 1.6.2 + xerces + xercesImpl + 2.11.0 diff --git a/src/main/java/com/docus/bgts/controller/BgtsController.java b/src/main/java/com/docus/bgts/controller/BgtsController.java index 1afea3b..6ef7fca 100644 --- a/src/main/java/com/docus/bgts/controller/BgtsController.java +++ b/src/main/java/com/docus/bgts/controller/BgtsController.java @@ -38,7 +38,7 @@ public class BgtsController { public CommonResult collect(@RequestParam("empId") String empId, @Param("collectSubId") String collectSubId) { try { logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); - bgtsService.collect(empId,collectSubId); + bgtsService.collect(empId); afCollectTaskService.updateInterfaceCollect(collectSubId, 1); } catch (RuntimeException e) { e.printStackTrace(); @@ -63,24 +63,17 @@ public class BgtsController { @ApiOperation("按需采集接口") @ApiImplicitParams({ @ApiImplicitParam(name = "emamNo",value = "报告单号",required = true,dataTypeClass = String.class), - @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), - @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true) + @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class) }) @GetMapping("/collectByExamNo") public CommonResult collectByExamNo(@RequestParam("emamNo") String emamNo, - @RequestParam("empId") String empId, - @Param("collectSubId") String collectSubId){ + @RequestParam("empId") String empId){ try { - logger.info("按需采集接口接受参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId+"\nemamNo--"+emamNo); - bgtsService.collectByExamNo(emamNo,empId,collectSubId); - afCollectTaskService.updateInterfaceCollect(collectSubId, 1); + logger.info("按需采集接口接受参数:\nempId--"+empId+"\nemamNo--"+emamNo); + bgtsService.collectByExamNo(emamNo,empId); +// afCollectTaskService.updateInterfaceCollect(collectSubId, 1); }catch (RuntimeException e) { e.printStackTrace(); - try { - afCollectTaskService.updateInterfaceCollect(collectSubId, 0); - }catch (Exception e1){ - return CommonResult.failed(e1.getMessage()); - } return CommonResult.failed(e.getMessage()); } catch (Exception e) { diff --git a/src/main/java/com/docus/bgts/facade/IBgtsService.java b/src/main/java/com/docus/bgts/facade/IBgtsService.java index bb334b8..c271eda 100644 --- a/src/main/java/com/docus/bgts/facade/IBgtsService.java +++ b/src/main/java/com/docus/bgts/facade/IBgtsService.java @@ -1,6 +1,5 @@ package com.docus.bgts.facade; -import javax.xml.rpc.ServiceException; import java.io.UnsupportedEncodingException; import java.rmi.RemoteException; @@ -9,15 +8,12 @@ public interface IBgtsService { * 采集 * @param empId */ - void collect(String empId, String collectSubId) throws Exception; + void collect(String empId) throws Exception; /** * 按需采集 * @param emamNo * @param empId - * @throws UnsupportedEncodingException - * @throws RemoteException - * @throws ServiceException */ - void collectByExamNo(String emamNo, String empId, String collectSubId) throws UnsupportedEncodingException, RemoteException, ServiceException, Exception; + void collectByExamNo(String emamNo, String empId) throws Exception; } diff --git a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java index a221c26..bf05c37 100644 --- a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java @@ -1,5 +1,6 @@ package com.docus.bgts.service; + import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.docus.bgts.entity.AfCollectTask; @@ -11,8 +12,10 @@ import com.docus.bgts.facade.IAfCollectTaskService; import com.docus.bgts.facade.IBgtsService; import com.docus.bgts.utils.FileUtils; import com.docus.bgts.utils.HttpUtils; +import com.docus.bgts.utils.JAXDynamicClientFactory; import com.docus.bgts.utils.XmlUtils; -import org.apache.axis.client.Call; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.cxf.endpoint.Client; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; @@ -20,13 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import javax.xml.namespace.QName; -import javax.xml.rpc.ParameterMode; -import javax.xml.rpc.ServiceException; -import javax.xml.rpc.encoding.XMLType; import java.io.ByteArrayInputStream; -import java.io.UnsupportedEncodingException; -import java.rmi.RemoteException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -36,8 +33,6 @@ import java.util.Map; public class BgtsServiceImpl implements IBgtsService { @Value("${ws.url}") private String wsUrl; - @Value("${ws.namespaceUrl}") - private String wsNamespaceUrl; @Value("${ws.localMethod}") private String wsLocalMethod; @@ -45,7 +40,7 @@ public class BgtsServiceImpl implements IBgtsService { IAfCollectTaskService afCollectTaskService; @Override - public void collect(String empId, String collectSubId) throws Exception { + public void collect(String empId) throws Exception { //通过empId获取报告单号集合 List exams = getExamNo(empId); //通过报告单号集合采集 @@ -53,7 +48,7 @@ public class BgtsServiceImpl implements IBgtsService { } @Override - public void collectByExamNo(String emamNo, String empId, String collectSubId) throws Exception { + public void collectByExamNo(String emamNo, String empId) throws Exception { String[] strings = new String[2]; //通过报告单号和系统id查询任务表 String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); @@ -71,7 +66,7 @@ public class BgtsServiceImpl implements IBgtsService { * @param exams * @param empId */ - private void collectExams(List exams, String empId) throws UnsupportedEncodingException, RemoteException, ServiceException { + private void collectExams(List exams, String empId) throws Exception { //获取插入表数据 ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId); //插入文件af_collect_task表数据 @@ -95,7 +90,7 @@ public class BgtsServiceImpl implements IBgtsService { * @param empId * @return */ - private ReportDownDto getUrlCreateReportDto(List exams, String empId) throws UnsupportedEncodingException, ServiceException, RemoteException { + private ReportDownDto getUrlCreateReportDto(List exams, String empId) throws Exception { ReportDownDto reportDownDto = new ReportDownDto(); ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); reportDownPatientDto.setJzh(empId); @@ -124,7 +119,7 @@ public class BgtsServiceImpl implements IBgtsService { * @param exam * @return */ - private ReportDownScanFileDto getScanByExam(String[] exam) throws UnsupportedEncodingException, ServiceException, RemoteException { + private ReportDownScanFileDto getScanByExam(String[] exam) throws Exception { ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); reportDownScanFileDto.setSerialnum(exam[0]); reportDownScanFileDto.setFiletitle(exam[1]); @@ -207,21 +202,35 @@ public class BgtsServiceImpl implements IBgtsService { return exams; } - public String invokeWs(String xml) throws ServiceException, RemoteException { - Object[] object = new Object[]{xml};//请求参数 - org.apache.axis.client.Service service = new org.apache.axis.client.Service(); - Call call = (Call) service.createCall(); - call.setTargetEndpointAddress(wsUrl);// 远程调用路径 - // 调用的命名空间和方法名 - call.setOperationName(new QName(wsNamespaceUrl, wsLocalMethod)); - call.setUseSOAPAction(true); -// call.setSOAPActionURI(wsNamespaceUrl + "pushSurveyReport"); - call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN); - call.setReturnType(XMLType.XSD_STRING);// 返回值类型:String - call.setTimeout(100000);//超时 - String result = (String) call.invoke(object);// 远程调用 - System.out.println(result); - return result; + + /** + * 调用web service + * @param xml + * @return + * @throws Exception + */ + public String invokeWs(String xml) throws Exception { +// Object[] object = new Object[]{xml};//请求参数 +// org.apache.axis.client.Service service = new org.apache.axis.client.Service(); +// Call call = (Call) service.createCall(); +// call.setTargetEndpointAddress(wsUrl);// 远程调用路径 +// // 调用的命名空间和方法名 +//// call.setOperationName(new QName(wsNamespaceUrl, wsLocalMethod)); +// call.setOperationName(wsLocalMethod); +// call.setUseSOAPAction(true); +//// call.setSOAPActionURI(wsNamespaceUrl + "pushSurveyReport"); +// call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN); +// call.setReturnType(XMLType.XSD_STRING);// 返回值类型:String +// call.setTimeout(100000);//超时 +// String result = (String) call.invoke(object);// 远程调用 +// System.out.println(result); + + JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance(); + Client client = dcf.createClient(wsUrl); + Object[] objects = client.invoke(wsLocalMethod,xml); + String str = objects[0].toString(); + System.out.println(str); + return str; } diff --git a/src/main/java/com/docus/bgts/utils/JAXDynamicClientFactory.java b/src/main/java/com/docus/bgts/utils/JAXDynamicClientFactory.java new file mode 100644 index 0000000..0b376f3 --- /dev/null +++ b/src/main/java/com/docus/bgts/utils/JAXDynamicClientFactory.java @@ -0,0 +1,51 @@ +package com.docus.bgts.utils; + +import org.apache.cxf.Bus; +import org.apache.cxf.bus.CXFBusFactory; +import org.apache.cxf.endpoint.EndpointImplFactory; +import org.apache.cxf.endpoint.dynamic.DynamicClientFactory; +import org.apache.cxf.jaxws.support.JaxWsEndpointImplFactory; + +import java.util.List; + +/** + * @ProjectName: + * @Description: + * @Param 传输参数 + * @Return + * @Author: 曾文和 + * @CreateDate: 2019/9/11 16:15 + * @UpdateUser: 曾文和 + * @UpdateDate: 2019/9/11 16:15 + * @UpdateRemark: 更新说明 + * @Version: 1.0 + */ +public class JAXDynamicClientFactory extends DynamicClientFactory { + protected JAXDynamicClientFactory(Bus bus) { + super(bus); + } + + @Override + protected EndpointImplFactory getEndpointImplFactory() { + return JaxWsEndpointImplFactory.getSingleton(); + } + @Override + protected boolean allowWrapperOps() { + return true; + } + + public static JAXDynamicClientFactory newInstance() { + Bus bus = CXFBusFactory.getThreadDefaultBus(); + return new JAXDynamicClientFactory(bus); + } + @Override + public boolean compileJavaSrc(String classPath, List srcList, String dest) { + org.apache.cxf.common.util.Compiler javaCompiler + = new org.apache.cxf.common.util.Compiler(); + javaCompiler.setEncoding("UTF-8"); + javaCompiler.setClassPath(classPath); + javaCompiler.setOutputDir(dest); + javaCompiler.setTarget("1.8"); + return javaCompiler.compileFiles(srcList); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0e07d47..bdb0031 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,10 +13,7 @@ mybatis-plus: db-type: MYSQL ws: - url: http://localhost:8010/ws_server/weather?wsdl - namespaceUrl: http://service.serviceserver.nanmeishu.com/ - localPart: TestServiceService - localPort: TestServicePort + url: http://192.168.1.115:8010/ws_server/weather?wsdl localMethod: OperationA spring: