1. public static long TIMEOUTINMILLISECONDS=100000;
  2. /**
  3. * 调用webservice
  4. * @param url webserviceURL
  5. * @param methodName 调用方法名
  6. * @param namespace 命名空间
  7. * @param params 参数
  8. * @param returnTypes 返回参数类型
  9. * @return
  10. * @throws AxisFault
  11. */
  12. public static <T> Object[] invokeMethod(String url,String methodName,String namespace,Object[] params,Class<T>[] returnTypes) throws AxisFault{
  13. RPCServiceClient client=new RPCServiceClient();
  14. Options options=client.getOptions();
  15. EndpointReference epr=new EndpointReference(url);
  16. options.setTo(epr);
  17. options.setTimeOutInMilliSeconds(TIMEOUTINMILLISECONDS);
  18. QName qName=new QName(namespace, methodName);
  19. Object[] results=client.invokeBlocking(qName, params, returnTypes);
  20. return results;
  21. }

调用方法

1、传递单个参数

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

2、传递数组

  1. 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});

axis2调用webservice的更多相关文章

  1. Java调用WebService方法总结(5)--Axis2调用WebService

    Axis2是新一点Axis,基于新的体系结构进行了全新编写,有更强的灵活性并可扩展到新的体系结构.文中demo所使用到的软件版本:Java 1.8.0_191.Axis2 1.7.9. 1.准备 参考 ...

  2. axis2调用webService几种方式

    主要有三种方式: 第一RPC方式,不生成客户端代码 第二,document方式,不生成客户端代码 第三,用wsdl2java工具,生成客户端方式调用 java代码: package samples.q ...

  3. axis2调用webservice教训

    总结教训,axis2client调用WS接口时url不能加?wsdl,而用cxf调用时则要加上. 今天用axis2的RpcServerClient调用https的webservice接口,在设置完op ...

  4. axis2 调用webservice

    maven配置:主要引用包及plugins <properties> <axis2.version>1.6.1</axis2.version> </prope ...

  5. 使用axis2调用webservice需要导入的依赖

    <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> &l ...

  6. Java调用WebService方法总结(1)--准备工作

    WebService是一种跨编程语言.跨操作系统平台的远程调用技术,已存在很多年了,很多接口也都是通过WebService方式来发布的:本系列文章主要介绍Java调用WebService的各种方法,使 ...

  7. 使用AXIS2客户端调用 WEBSERVICE

    问题 在调用WEBSERVICE时,可以使用wsdl2java生成java代码,调用接口,这种方法在接口固定的情况下是一种不错的选择,如果需要动态调用接口,那么这样就行不通了. 解决办法 1.直接构建 ...

  8. 使用Axis2实现WebService的发布和调用

    一.Axis2的下载和安装 1.可从http://ws.apache.org/axis2/ 下载Axis2的最新版本:      可以下载如下三个zip包: axis2-1.7.3-bin.zip(用 ...

  9. Axis2 webservice 之使用java调用webservice

    在上一篇中写了一个简单了webservice,实现了一个sayHello功能.那么webservice写好之后我们如何使用Java程序来调用webservice呢? 一.java调用的webservi ...

随机推荐

  1. apache开源项目--CouchDB

    Apache CouchDB 是一个面向文档的数据库管理系统.它提供以 JSON 作为数据格式的 REST 接口来对其进行操作,并可以通过视图来操纵文档的组织和呈现. CouchDB 是 Apache ...

  2. NEsper事件处理 z

    http://esper.codehaus.org/nesper/documentation/documentation.html 环境配置 NEsper库下载:下载网址 Vs2010环境集成 在项目 ...

  3. oracle执行.sql文件

    ->win+R; ->CMD; ->SQLPLUS /NOLOG; ->CONNECT USER/PASSWORD@ORCL; ->@D:/XXX.SQL;

  4. Ruby应用记录:修改文件中某个字符串

    #修改android客户端中服务器地址的默认值为对应环境的服务器地址 #!/usr/bin/ruby ostr="192.168.88.95:8088" nstr="19 ...

  5. Installing EF Power Tools into VS2015

    TLDR: If you don’t want to do the tasks (even though they are so easy) you can download the updated ...

  6. bzoj 2281 [Sdoi2011]黑白棋(博弈+组合计数)

    黑白棋(game) [问题描述] 小A和小B又想到了一个新的游戏. 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色. 最左边是白色棋子,最右边是黑色棋子,相邻的棋子颜色 ...

  7. sed命令教程

    转载自:http://coolshell.cn/articles/9104.htmlawk于1977年出生,今年36岁本命年,sed比awk大2-3岁,awk就像林妹妹,sed就是宝玉哥哥了.所以 林 ...

  8. HW4.12

    public class Solution { public static void main(String[] args) { int n = 0; while(n * n < 12000) ...

  9. POJ1050:To the max

    poj1050:http://poj.org/problem?id=1050 * maximum-subarray 问题的升级版本~ 本题同样是采用DP思想来做,同时有个小技巧处理:就是把二维数组看做 ...

  10. poj 2117 Electricity【点双连通求删除点后最多的bcc数】

    Electricity Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4727   Accepted: 1561 Descr ...