package ws;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
//执行前需导入<AXIS_HOME>/lib目录下所有jar包 以及 mail.jar、activation.jar。
public class CallWebServiceClient {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) {
try {
// 调用定制发布的web服务。
// String endpoint = "http://localhost:8080/axis/services/urn:Capacity";
// 调用即时发布的web服务。
String endpoint = http://localhost:8080/axis/Hello.jws;
Service service = new Service();
Call call = null;
call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("sayHello");//要调用的方法名
call.setReturnType(call.getReturnType());
String ret = (String)call.invoke( new Object[]{"Neil"});//参数值:Neil
System.out.println(ret);
} catch (Exception e) {
System.out.println(e);
} finally {
}
}
}