Axis1 调用WebService接口


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();  
    }

    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM