Axis2 服务四种客户端调用方式:

1.AXIOMClient

2.generating a client using ADB

3.generating a client using XMLBeans

4.generating a client using JiBX

http://axis.apache.org/axis2/java/core/ 官方

搜索了很多资料,没有找到合适的。不论是插件生成还是AXIOMClient使用起来都很麻烦。

service:

public interface TestService {
public List<Person> findAll();
public Person getWhere(List<Person> persons);//3.传入集合,返回对象
public List<Person> getWheres(List<Person> persons);//4.传入集合,返回集合
public Person getChild(Person p); //1.传入对象,返回对象
public List<Person> getChildren(Person p);//2.传入对象,返回集合 }

要达成上面的目的应该能够满足大部分场景的使用。那么我们接下在这样做。

client:

1.传入对象,返回对象

 private static  void test01ParameterIsObjectReturnObject()
{

//客户端调用要简单。传入下面的值就能调用服务方法
        //服务地址,命名空间,方法名,参数
     System.out.println("=====================test01[the parameter is a object and return a object] begin:");
axis2Context.setFunctionName("getChild");
Map<String,Object> map = new HashMap<String,Object>();
map.put("p", CreatePerson());
axis2Context.setFunctionPrameters(map);
Person person = Axis2Help.invoke(axis2Context, Person.class);
System.out.println("the result:" + person.getName());
System.out.println("=============================================================================end");
}

 返回结果:

==========================================test01[the parameter is a object and return a object] begin:
the result:张三返回值
=============================================================================end

2.传入对象,返回集合

 private static  void test02ParameterIsObjectReturnList()
{
System.out.println("=====================test02[the parameter is a object and return list] begin:");
axis2Context.setFunctionName("getChildren");
Map<String,Object> map = new HashMap<String,Object>();
map.put("p", CreatePerson());
axis2Context.setFunctionPrameters(map);
List<Person> persons = Axis2Help.invokeForList(axis2Context, Person.class);
System.out.println("the result persons.size():" + persons.size() );
System.out.println("=============================================================================end");
}

 返回结果:

==========================================test02[the parameter is a object and return list] begin:
the result persons.size():2
=============================================================================end

3.传入集合返回对象

 System.out.println("=====================test03[the parameter is list and return a object] begin:");
axis2Context.setFunctionName("getWhere");
Map<String,Object> map = new HashMap<String,Object>();
map.put("persons", CreatePersonList());
axis2Context.setFunctionPrameters(map);
Person person = Axis2Help.invoke(axis2Context, Person.class);
System.out.println("the result:" + person.getName());
System.out.println("=============================================================================end");

  返回结果:

=====================test03[the parameter is list and return a object] begin:
the result:张三:返回值
=============================================================================end

4.传入集合返回集合

 private static  void test04ParameterIsListReturnList()
{
System.out.println("=====================test04[the parameter is list and return a list] begin:");
axis2Context.setFunctionName("getWheres");
Map<String,Object> map = new HashMap<String,Object>();
map.put("persons", CreatePersonList());
axis2Context.setFunctionPrameters(map);
List<Person> persons = Axis2Help.invokeForList(axis2Context, Person.class);
System.out.println("the result:" + persons.size());
System.out.println("=============================================================================end");
}

  返回结果:

==========================================test04[the parameter is list and return a list] begin:
the result:2
=============================================================================end

参数类型:Person 是复杂自定义类型。

结束

Axis2Service客户端访问通用类集合List自定义类型的更多相关文章

  1. C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]

    原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...

  2. C#---数据库访问通用类、Access数据库操作类、mysql类 .

    //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using System. ...

  3. [c#基础]泛型集合的自定义类型排序

    引用 最近总有种感觉,自己复习的进度总被项目中的问题给耽搁了,项目中遇到的问题,不总结又不行,只能将复习基础方面的东西放后再放后.一直没研究过太深奥的东西,过去一年一直在基础上打转,写代码,反编译,不 ...

  4. C# 泛型集合的自定义类型排序

    一.泛型集合List<T>排序 经sort方法之后,采用了升序的方式进行排列的. List<int> list = new List<int>() { 2, 4, ...

  5. HashSet存储自定义类型元素和LinkedHashSet集合

    HashSet集合存储自定义类型元素 HashSet存储自定义类型元素 set集合报错元素唯一: ~存储的元素(String,Integer,-Student,Person-)必须重写hashCode ...

  6. [转]DbHelper通用数据库访问帮助类

    之前我一直都是在博客园中查看各位高手的博文,确实学到了不少知识,不过比较少写博客,现在就把我自己在项目实施过程中使用到比较好的技术框架写出来,希望能让更多的人了解和学习. 通常我们在开发使用数据库访问 ...

  7. sharepoint 2010自定义访问日志列表设置移动终端否和客户端访问系统等计算列的公式

    上个月本人开发和上线了一个在SharePoint 2010上基于HTML5的移动OA网站,后端服务采用自定义的基于AgilePoint工作流引擎的Sharepoint Web服务,前端主要采用Jque ...

  8. java数据类型:集合存储元素类型限制<泛型> ;自定义类指定泛型<T> 以及限制用法;派生子类泛型<T> super(泛型内参数); 泛型通配符?以及?限制用法

    问题背景 Java 集合有个缺点,把一个对象"丢进"集合里之后,集合就会"忘记"这个对象的数据类型,当再次取出该对象时 该对象的编译类型就变Object类型(其 ...

  9. NPOI MVC 模型导出Excel通用类

    通用类: public enum DataTypeEnum { Int = , Float = , Double = , String = , DateTime = , Date = } public ...

随机推荐

  1. transition状态下Mecanim动画的跳转

    来自: http://blog.csdn.net/o_oxo_o/article/details/21325901 Unity中Mecanim里面动画状态的变化,是通过设置参数(Parameter)或 ...

  2. HDU - 3038 How Many Answers Are Wrong (带权并查集)

    题意:n个数,m次询问,每次问区间a到b之间的和为s,问有几次冲突 思路:带权并查集的应用.[a, b]和为s,所以a-1与b就能够确定一次关系.通过计算与根的距离能够推断出询问的正确性 #inclu ...

  3. KINavigationController使用演示例子

    代码地址如下:http://www.demodashi.com/demo/12905.html 运行效果 实现思路 创建pan手势,添加到页面中,监听手势的动作.重写push的方法,在push之前截图 ...

  4. java之this关键字

    this使用范围 1.在类的方法定义中使用的this关键字代表调用该方法对象的引用. 2.当必须指出当前使用方法的对象是谁时,要使用关键字this. 3.有时使用this可以处理方法中成员变量和参数重 ...

  5. webpack打包vue2.0项目时必现问题(转载)

    原文地址:http://www.imooc.com/article/17868 [Vue warn]: You are using the runtime-only build of Vue wher ...

  6. Coolite简介

    Coolite Toolkit 简介 Coolite Toolkit 是一个支持ASP.NET AJAX的Web控件 Coolite Toolkit是基于跨浏览器的ExtJS 库开发而来的,并且简化了 ...

  7. 知也atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException  v2 q31无涯 - I

    atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerExceptionv2 q31 1. #--现象 java.lang. ...

  8. Atitit.python web环境的配置 attilax 总结

    Atitit.python web环境的配置 attilax 总结 1. 下载modpython/1 1.1. 安装python2.5.11 1.2. 安装modpython1 2. 设置py文件的u ...

  9. 迁移TFS 2012服务至新的电脑硬件

    迁移TFS 2012的时候碰到一些问题, 中文记录很少, 英文的记录也比较零散. 这里记录最直接和简单的方法. 环境: 1. 公司域环境, 所有TFS用户都是公司域帐户. 2. TFS从一台服务器转移 ...

  10. DM36x IPNC OSD显示中文 --- 实战篇

    通过数据准备篇,将数据准备好后,其实剩下的工作已经很简单了,通过以下几个步骤即可把一个中文显示在OSD画面上:1. 使用SWOSD_setBmpchangeWinXYPrm函数设置好OSD显示坐标位置 ...