zoukankan      html  css  js  c++  java
  • axis2调用webservice

    	public static long TIMEOUTINMILLISECONDS=100000;
    	/**
    	 * 调用webservice
    	 * @param url webserviceURL
    	 * @param methodName 调用方法名
    	 * @param namespace 命名空间
    	 * @param params 参数
    	 * @param returnTypes 返回参数类型
    	 * @return
    	 * @throws AxisFault
    	 */
    	public static <T> Object[] invokeMethod(String url,String methodName,String namespace,Object[] params,Class<T>[] returnTypes) throws AxisFault{
    		RPCServiceClient client=new RPCServiceClient();
    		Options options=client.getOptions();
    		EndpointReference epr=new EndpointReference(url);
    		options.setTo(epr);
    		options.setTimeOutInMilliSeconds(TIMEOUTINMILLISECONDS);
    		QName qName=new QName(namespace, methodName);
    		Object[] results=client.invokeBlocking(qName, params, returnTypes);
    		return results;
    	}
    

     调用方法

    1、传递单个参数

    Object[] objs = invokeMethod("http://localhost:8080/axis2/services/MobileWs", "getArrayTest", "http://ws.apache.org/axis2", new Object[] {"zhangsan"}, new Class[]{String.class});
    

     2、传递数组

    Object[] objs = invokeMethod("http://localhost:8080/axis2/services/MobileWs", "getArrayTest", "http://ws.apache.org/axis2", new Object[] {new String[]{"zhangsan","lisi"}}, new Class[]{String.class});
    
  • 相关阅读:
    使用phpize安装php模块
    centos如何卸载软件
    修改centos环境变量
    linux系统安装php扩展
    php单入口session处理
    session阻塞机制,解决方法
    uploadify插件的使用
    php图片上传代码
    validate插件的使用
    datepicker使用
  • 原文地址:https://www.cnblogs.com/Laupaul/p/3564224.html
Copyright © 2011-2022 走看看