//WSDL路径
String wsUrl = "http://localhost:8082/ws/services/bank?wsdl" ; //方法名
String method = "getCaseProve"; JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); Client client = factory.createClient(wsUrl); Endpoint endpoint = client.getEndpoint(); QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), method); BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding(); System.out.println(client); if (bindingInfo.getOperation(opName) == null) { for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) { if (method.equals(operationInfo.getName().getLocalPart())) { opName = operationInfo.getName(); break; } } }
//请求报文 String xmlInput= "<Request RequestType=\"RegInfo\"><MachineInfo MachineAccount=\"1\" MachinePassword=\"1\"></MachineInfo><FiterInfo UnitNo=\"" + unit + "\" HouseID=\"" + houseId + "\" RecHouseNum=\"" + recHouseNum + "\"></FiterInfo></Request>"; Object[] res = null; try { res = client.invoke(opName, xmlInput); String xml = (String) res[0]; System.err.println("@@@@@@@@@@@@@@@@@"+xml); } catch (Exception e) { e.printStackTrace(); }
Java使用JaxWsDynamicClientFactory调取基于cxf的soap风格webservice的接口
猜你喜欢
转载自www.cnblogs.com/gaomanito/p/10043753.html
今日推荐
周排行