import java.rmi.RemoteException; import javax.xml.namespace.QName; import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class Test { private static String endPoint="http://localhost:8080/WebServiceDemo/services/myService"; /** * @param args * @throws ServiceException * @throws RemoteException */ public static void main(String[] args) throws ServiceException, RemoteException { Service service = new Service(); try { //创建服务方法的调用者对象call,设置call对象的属性 Call call = (Call) service.createCall(); call.setTargetEndpointAddress(endPoint);//设置服务终端地址 QName opAddEntry = new QName("http://service", "sayHello");//设置NameSpace和方法 call.setOperationName(opAddEntry);//请求对象设置QName对象,这个英文应该是QuestionName String result = (String) call.invoke(new Object[] {"RYL"});//请求对象注入返回结果参数 System.out.println("result is "+result); } catch (Exception e) { e.printStackTrace(); } } }