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});
    
  • 相关阅读:
    monaco editor
    javascript for of 和 for in 在数组和对象中的区别
    django rest 版本控制器
    学习
    day 22
    day 21
    day20
    day21 数据处理自我小结
    day20 【手写数字识别】之数据处理(搬运)
    day19 通过极简方案快速构建手写数字识别模型 (百度飞浆搬运)
  • 原文地址:https://www.cnblogs.com/Laupaul/p/3564224.html
Copyright © 2011-2022 走看看