调用WebService接口返回字符串

 1 Service service = new Service();
 2             Call call = (Call) service.createCall();
 3             call.setTargetEndpointAddress(this.endPoint);
 4             call.setOperationName(new QName(this.defaultNameSpace,this.interfaceMethodName));
 5             call.setSOAPActionURI(this.defaultNameSpace + "/"+ this.interfaceMethodName);
 6             
 7             if (this.methodParameter.contains(",")) {
 8                 String[] paramter = this.methodParameter.split(",");
 9                 for (int i = 0; i < paramter.length; i++) {
10                     // 接口的参数
11                     call.addParameter(new QName(this.defaultNameSpace,paramter[i]), Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
12                 }
13             } else {
14                 // 接口的参数
15                 call.addParameter(new QName(this.defaultNameSpace,this.methodParameter), Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
16             }
17             // 设置返回类型
18             call.setReturnType(Constants.XSD_STRING);
19 
20             Object[] strs = new Object[] { strDate, hour };
21             String returnVal = (String) call.invoke(strs);
22             // 给方法传递参数,并且调用方法
23             System.out.println("returnVal is " + returnVal);
原文地址:https://www.cnblogs.com/bilaisheng/p/4976118.html