import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class Client {
public static void main(String[] args) {
String str = "hello";
String endpoint = "http://localhost:8080/services/DataCenterService";//接口调用地址
String result = null;
try {
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName(new QName("http://service/", "test"));//接口方法名
//注意:设置参数默认为arg0,否则参数会无法传递过去
call.addParameter("arg0", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
result = (String)call.invoke(new Object[]{str});//接口参数
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
}
java调用WebService接口
最新推荐文章于 2023-02-04 21:34:02 发布