package vedio.webservice;
import java.net.URL;
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) {
Service service = new Service();
try {
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new URL("http://localhost/simple/webservice/webserviceHello?wsdl"));
call.setOperationName(new QName("http://java.com/","sayHai"));//前面为命名空间,后面为调用方法名,http://后面为接口所在的包名,逆序,一直到src下
call.addParameter(new QName("name"), org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//返回参数类型
String result = (String) call.invoke(new Object[]{"test"});
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
}