Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/FindPatientInfoByHospitalNumDaoImpl.java =================================================================== diff -u -r29499 -r29504 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/FindPatientInfoByHospitalNumDaoImpl.java (.../FindPatientInfoByHospitalNumDaoImpl.java) (revision 29499) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/FindPatientInfoByHospitalNumDaoImpl.java (.../FindPatientInfoByHospitalNumDaoImpl.java) (revision 29504) @@ -16,8 +16,11 @@ import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.directory.vo.LoginUserData; import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.tools.date.DateTools; /** * 根据住院号查询病人信息(南方医院) @@ -33,9 +36,11 @@ @Override public PatientInfoVO[] findPatientInfoByHospitalNum(String hospitalNum) { try { - String inputXml = WebServiceClientHelper.buildInputString(DatasyncConstant.ServiceCode_PATPatientID, hospitalNum); - logger.info("病人信息同步接口请求信息:" + inputXml); - String result = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebserviceAddress, inputXml, ""); + LoginUserData loginUserData = AcegiHelper.getLoginUser(); + String ExtUserID = loginUserData.getUserName(); + String input2 = "丁香软件" + hospitalNum + "" + ExtUserID + "" + DateTools.getFormatDateStr(new Date(), "yyyy-MM-dd") + "" + DateTools.getCurrentYearEnd() + ""; + logger.info("病人信息同步接口请求信息:" + input2); + String result = WebServiceClientHelper.axisInvokeWebservice(DatasyncConstant.ServiceCode_PATPatientID, input2); /*String result = "" + "" + "" @@ -97,13 +102,13 @@ patientInfoArr = (JSONArray) patientInfoObj; }else if(patientInfoObj instanceof JSONObject){ patientInfoArr = new JSONArray(); - patientInfoArr.add(patientInfoObj); + JSONObject patientInfo = ((JSONObject)patientInfoObj).optJSONObject("AdmNoInfo"); + patientInfoArr.add(patientInfo); } if(patientInfoArr != null && patientInfoArr.size() > 0){ List patientInfoVOList = new ArrayList(); for (Object object : patientInfoArr) { - JSONObject patientObject = (JSONObject) object; - JSONObject patientInfo = patientObject.optJSONObject("AdmNoInfo"); + JSONObject patientInfo = (JSONObject) object; Object tNumber = patientInfo.opt("PATPatientID"); Object patientName = patientInfo.opt("Name"); Object patientAge = patientInfo.opt("Age"); @@ -178,9 +183,11 @@ } String AdmNo = patientInfoVO.getAdmNo(); try { - String inputXml = WebServiceClientHelper.buildInputString(DatasyncConstant.ServiceCode_AdmNo, AdmNo); - logger.info("手术信息同步接口请求信息:" + inputXml); - String result = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebserviceAddress, inputXml, ""); + LoginUserData loginUserData = AcegiHelper.getLoginUser(); + String ExtUserID = loginUserData.getUserName(); + String input2 = "丁香软件" + ExtUserID + "" + AdmNo + ""; + logger.info("手术信息同步接口请求信息:" + input2); + String result = WebServiceClientHelper.axisInvokeWebservice(DatasyncConstant.ServiceCode_AdmNo, input2); /*String result = "" + "" + "" @@ -262,13 +269,13 @@ opeartionInfoArr = (JSONArray) opeartionInfoObj; }else if(opeartionInfoObj instanceof JSONObject){ opeartionInfoArr = new JSONArray(); - opeartionInfoArr.add(opeartionInfoObj); + JSONObject opeartionInfo = ((JSONObject)opeartionInfoObj).optJSONObject("OperationAppInfo"); + opeartionInfoArr.add(opeartionInfo); } if(opeartionInfoArr != null && opeartionInfoArr.size() > 0){ List opeartionInfoVOList = new ArrayList(); for (Object object : opeartionInfoArr) { - JSONObject opeartionObject = (JSONObject) object; - JSONObject opeartionInfo = opeartionObject.optJSONObject("OperationAppInfo"); + JSONObject opeartionInfo = (JSONObject) object; Object OperRoom = opeartionInfo.opt("OperRoom"); Object doctorName = opeartionInfo.opt("DoctorDesc"); Object operation = opeartionInfo.opt("OperDesc"); Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/DatasyncConstant.java =================================================================== diff -u -r29499 -r29504 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/DatasyncConstant.java (.../DatasyncConstant.java) (revision 29499) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/DatasyncConstant.java (.../DatasyncConstant.java) (revision 29504) @@ -9,9 +9,9 @@ public class DatasyncConstant { /** - * Webservice地址 + * Webservice地址 */ - public final static String WebserviceAddress = "http://192.168.128.170/csp/hsb/DHC.Published.PUB0028.BS.PUB0028.CLS?WSDL=1"; + public final static String WebserviceAddress = "http://192.168.128.170/csp/hsb/DHC.Published.PUB0028.BS.PUB0028.cls"; /** * 按病人ID号查询病人信息的服务编码 Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/WebServiceClientHelper.java =================================================================== diff -u -r29499 -r29504 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/WebServiceClientHelper.java (.../WebServiceClientHelper.java) (revision 29499) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/nfykdxnfyy/WebServiceClientHelper.java (.../WebServiceClientHelper.java) (revision 29504) @@ -1,23 +1,11 @@ package com.forgon.disinfectsystem.datasynchronization.dao.nfykdxnfyy; -import java.nio.charset.Charset; -import java.util.Date; +import javax.xml.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.axis.client.Call; +import org.apache.axis.client.Service; import org.apache.log4j.Logger; -import com.forgon.directory.acegi.tools.AcegiHelper; -import com.forgon.directory.vo.LoginUserData; -import com.forgon.tools.date.DateTools; - /** * 南方医院webservice帮助类 * @author ZhouPeiMian @@ -28,84 +16,54 @@ public static Logger logger = Logger.getLogger(WebServiceClientHelper.class); - /** - * 构造接口输入参数 - * @param serviceCode - * @param arg - * @return - */ - public static String buildInputString(String serviceCode, String... arg){ - String inputXml = ""; - LoginUserData loginUserData = AcegiHelper.getLoginUser(); - String ExtUserID = loginUserData.getUserName(); - if(StringUtils.equals(serviceCode, DatasyncConstant.ServiceCode_PATPatientID)){ - StringBuffer inputXmlSB = new StringBuffer(); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append("" + serviceCode + ""); - inputXmlSB.append("丁香软件" + arg[0] + "" + ExtUserID + "" + DateTools.getFormatDateStr(new Date(), "yyyy-MM-dd") + "" + DateTools.getCurrentYearEnd() + "]]>"); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXml = inputXmlSB.toString(); - }else if(StringUtils.equals(serviceCode, DatasyncConstant.ServiceCode_AdmNo)){ - StringBuffer inputXmlSB = new StringBuffer(); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append("" + serviceCode + ""); - inputXmlSB.append("丁香软件" + ExtUserID + "" + arg[0] + "]]>"); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXmlSB.append(""); - inputXml = inputXmlSB.toString(); - }else { - throw new RuntimeException("服务编码错误:" + serviceCode); - } - return inputXml; - } - - /** - * 使用SOAP1.2发送消息 - * - * @param postUrl - * @param soapXml - * @param soapAction + /** + * axis调用webservice + * @param input1 + * @param input2 * @return + * @throws Exception */ - public static String doPostSoap1_2(String postUrl, String soapXml, String soapAction) { - String retStr = ""; - // 创建HttpClientBuilder - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - // HttpClient - CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); - HttpPost httpPost = new HttpPost(postUrl); - // 设置请求和传输超时时间 - RequestConfig requestConfig = RequestConfig.custom() - .setSocketTimeout(3000000) - .setConnectTimeout(3000000).build(); - httpPost.setConfig(requestConfig); - try { - httpPost.setHeader("Content-Type", "application/soap+xml;charset=UTF-8"); - httpPost.setHeader("action", "HIPMessageServer"); - StringEntity data = new StringEntity(soapXml,Charset.forName("UTF-8")); - httpPost.setEntity(data); - CloseableHttpResponse response = closeableHttpClient.execute(httpPost); - HttpEntity httpEntity = response.getEntity(); - if (httpEntity != null) { - // 打印响应内容 - retStr = EntityUtils.toString(httpEntity, "UTF-8"); - retStr = retStr.replaceAll("<", "<"); - retStr = retStr.replaceAll(">", ">"); - retStr = retStr.replaceAll(""", "\""); - } - // 释放资源 - closeableHttpClient.close(); - } catch (Exception e) { - logger.info("exception in doPostSoap1_2:" + e); - } - return retStr; - } + public static String axisInvokeWebservice(String input1, String input2) throws Exception { + //字符集 + String encodingStyle = "utf-8"; + //WSDL的地址 + String endpoint = DatasyncConstant.WebserviceAddress; + //命名空间,在WSDL中对应的标签是:targetNamespace                                     + String targetNamespace = "http://tempuri.org"; + //具体方法的调用URI,在WSDL中对应的标签是: + String soapActionURI = "http://tempuri.org/DHC.Published.PUB0028.BS.PUB0028.HIPMessageServer"; + //具体调用的方法名,在WSDL中对应的标签是: + String method = "HIPMessageServer"; + //调用接口的参数的名字 + String[] paramNames = {"input1","input2"}; + //调用接口的参数的值 + String param1 = input1; + + String param2 = input2; + + logger.info("input1 : " + param1); + logger.info("input2 : " + param2); + + Service service = new Service(); + Call call = (Call) service.createCall(); + //call.setTimeout(new Integer(20000)); //设置超时时间 + call.setSOAPActionURI(soapActionURI); + call.setTargetEndpointAddress(new java.net.URL(endpoint)); //设置目标接口的地址 + call.setEncodingStyle(encodingStyle);//设置传入服务端的字符集格式如utf-8等 + call.setOperationName(new QName(targetNamespace, method));// 具体调用的方法名,可以由接口提供方告诉你,也可以自己从WSDL中找 + call.setUseSOAPAction(true); + call.addParameter(paramNames[0], + org.apache.axis.encoding.XMLType.XSD_STRING, + javax.xml.rpc.ParameterMode.IN);// 接口的参数 + call.addParameter(paramNames[1], + org.apache.axis.encoding.XMLType.XSD_STRING, + javax.xml.rpc.ParameterMode.IN);// 接口的参数 + call.setReturnClass(java.lang.String.class); //返回字符串类型 + // 给方法传递参数,并且调用方法 ,如果无参,则new Obe + String result = (String)call.invoke(new String[] {param1, param2}); + // 打印返回值 + logger.info("result is " + result); + return result; + } }