导入jar包
<dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.lucee</groupId> <artifactId>jaxrpc</artifactId> <version>1.4.0</version> </dependency> <dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId> <version>0.5</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> java方法 public void callMeth() throws RemoteException, javax.xml.rpc.ServiceException, MalformedURLException { String url = "http://jsxngx.seu.edu.cn/WebService/ResourceService.asmx";//提供接口的地址 String soapaction = "http://tempuri.org/"; //命名空间 和webservic中的targetNamespace对应 String json = "{\n" + " \"UnitCode\": \"320001\",\n" + " \"Account\": \"admin\",\n" + " \"PushTime\": \"201710122523002\",\n" + " \"EvaluationReportMainList\": [\n" + " {\n" + " \"ResourceName\": \"实验资源名称1\",\n" + " \"EvaluationReportList\": [\n" + " {\n" + " \"UserName\": \"评价人1\",\n" + " \"UserNo\": \"123\",\n" + " \"EvaluationContent\": \"评价内容\",\n" + " \"CreateDate\": \"/Date(1512573800000)/\"\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"ResourceName\": \"实验资源名称2\",\n" + " \"EvaluationReportList\": [\n" + " {\n" + " \"UserName\": \"评价人2\",\n" + " \"UserNo\": \"124\",\n" + " \"EvaluationContent\": \"评价内容\",\n" + " \"CreateDate\": \"/Date(1512573800000)/\"\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}" ; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(url)); call.setOperationName(new QName(soapaction, "AddEvaluationReport"));//命名空间 调用的方法名 call.addParameter(new QName(soapaction ,"json"), Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);//传递的参数 call.setReturnType(Constants.XSD_BOOLEAN);//(标准的类型) call.setUseSOAPAction(true); call.setSOAPActionURI(soapaction + "AddEvaluationReport"); Boolean aa =(Boolean) call.invoke(new String[]{json}); System.out.println(aa);//输出返回值 }