提供了webservice的wsdl地址,如何生成消费端(客户端),怎么调用已经提供的wsdl接口
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了提供了webservice的wsdl地址,如何生成消费端(客户端),怎么调用已经提供的wsdl接口相关的知识,希望对你有一定的参考价值。
1、新建一个java项目,然后新建web service client。
2、输入wsdl地址
3、生成的消费端目录如下
如何根据提供的wsdl地址调用接口(传参和返回值的处理)
1 public static Map<String, Object> queryRecordMsg(String contNo){ 2 3 Map<String,Object> rootResult = new HashMap<String,Object>(); 4 try{ 5 UnderwritingHistoryInformationQuerySrvBindingQSService service = new UnderwritingHistoryInformationQuerySrvBindingQSService(); 6 UnderwritingHistoryInformationQuerySrvPortType portType = service.getUnderwritingHistoryInformationQuerySrvBindingQSPort(); 7 SysMsgHeader parametersReqHeader = new SysMsgHeader(); 8 parametersReqHeader.setMsgId(makeTransNo()); 9 parametersReqHeader.setMsgDate(DateUtil.getCurrentDateStr()); 10 parametersReqHeader.setMsgTime(DateUtil.getCurrentTimeStr()+".000"); 11 parametersReqHeader.setServCd("P00001000884"); 12 parametersReqHeader.setSysCd("055"); 13 parametersReqHeader.setBizId("03_02_01_I01"); 14 parametersReqHeader.setBizType(""); 15 parametersReqHeader.setOrgCd("86"); 16 parametersReqHeader.setResCd(""); 17 parametersReqHeader.setResText(""); 18 parametersReqHeader.setBizResCd(""); 19 parametersReqHeader.setBizResText(""); 20 parametersReqHeader.setVer("110.100.000"); 21 //业务报文 22 com.newchinalife.service.bd.p00001000884.SrvReqBody parametersReqBody = new com.newchinalife.service.bd.p00001000884.SrvReqBody(); 23 //业务报文头 24 SRVReqHead srvReqHead = new SRVReqHead(); 25 srvReqHead.setOperator("ebt"); 26 srvReqHead.setRowNumStart("1"); 27 srvReqHead.setPageRowNum("10"); 28 srvReqHead.setPageFlag("0"); 29 srvReqHead.setTotalRowNum(""); 30 srvReqHead.setOrderFlag("0"); 31 srvReqHead.setOrderField(""); 32 parametersReqBody.setBizHeader(srvReqHead); 33 //业务报文体 34 com.newchinalife.service.bd.p00001000884.SrvReqBizBody srvReqBizBody = new com.newchinalife.service.bd.p00001000884.SrvReqBizBody(); 35 com.newchinalife.service.bd.p00001000884.InputData inputData = new com.newchinalife.service.bd.p00001000884.InputData(); 36 inputData.setPolno(contNo);// 存入投保单号 37 srvReqBizBody.setInputData(inputData); 38 parametersReqBody.setBizBody(srvReqBizBody); 39 //初始化响应的对象 40 Holder<SysMsgHeader> parametersResHeader = new Holder<SysMsgHeader>(); 41 Holder<com.newchinalife.service.bd.p00001000884.SrvResBody> parametersResBody = new Holder<com.newchinalife.service.bd.p00001000884.SrvResBody>(); 42 portType.underwritingHistoryInformationQuery(parametersReqHeader, parametersReqBody, parametersResHeader, parametersResBody); 43 String resultCode = parametersResHeader.value.getBizResCd(); 44 String resultMsg = parametersResHeader.value.getBizResText(); 45 log.error("根据投保单号:"+contNo+"查询承保操作履历,resultCode:"+resultCode+",resultMsg:"+resultMsg); 46 List<HashMap<String, Object>> resultList = new ArrayList<HashMap<String, Object>>(); 47 48 if ("0".equals(resultCode)) { 49 List<com.newchinalife.service.bd.p00001000884.Result> results = parametersResBody.value.getBizBody().getOutputData().getResult(); 50 for(com.newchinalife.service.bd.p00001000884.Result result :results){ 51 HashMap<String, Object> resultMap = new HashMap<String,Object>(); 52 resultMap.put("rowNo", result.getRowNo()); 53 resultMap.put("polNo", result.getPolNo()); 54 resultMap.put("opertor", result.getOperator()); 55 resultMap.put("startDate", result.getStartDate()); 56 resultMap.put("enDate", result.getEndDate()); 57 resultMap.put("state", result.getState()); 58 resultList.add(resultMap); 59 } 60 } 61 rootResult.put("resultCode", resultCode); 62 rootResult.put("resultMsg", resultMsg); 63 rootResult.put("resultList", resultList); 64 return rootResult; 65 }catch (Exception e) { 66 e.printStackTrace(); 67 } 68 return rootResult; 69 }
总结:
以上代码均为项目中涉及到的,希望对大家有帮助,如有问题,可QQ联系。
以上是关于提供了webservice的wsdl地址,如何生成消费端(客户端),怎么调用已经提供的wsdl接口的主要内容,如果未能解决你的问题,请参考以下文章