webservice调用工具类
添加依赖: <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>javax.xml.rpc</groupId> <artifactId>javax.xml.rpc-api</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.apache.geronimo.bundles</groupId> <artifactId>commons-discovery</artifactId> <version>0.4_1</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.3</version> </dependency> 测试方法: public static void main(String[] args) throws Exception { try { String endpoint = "http://127.0.0.1:8082/sibpm-osa-f/services/syDdProjectAcceptServiceImpl?wsdl"; // 直接引用远程的wsdl文件 // 以下都是套路 Service service = new Service(); Call call = (Call) service.createCall(); call.setEncodingStyle("utf-8"); call.setTargetEndpointAddress(endpoint); call.setOperationName( new QName("http://read.service.osa.api.sibpm.com/","sendResult") );// WSDL里面描述的接口名称 call.addParameter("arg0", Constants.XSD_STRING, String.class, javax.xml.rpc.ParameterMode.IN);// 接口的参数 call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// 设置返回类型 Map param = new HashMap(); param.put("project_no","21060020201202000006"); param.put("resultCode","0"); param.put("create_by","123"); param.put("create_name","小张"); param.put("create_dept","949849"); param.put("create_dept_name","工伤部"); String temp = JsonUtil.toJson(param); String result = (String) call.invoke(new Object[] { temp }); // 给方法传递参数,并且调用方法 System.out.println("result is " + result); } catch (Exception e) { System.err.println(e.toString()); }