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. Selenium webdriver Java 操作IE浏览器

    V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...

  2. Photoshop | 快速抠头发(调整边缘/选择并遮住)

    ———————————————————————————————————————————— Photoshop快速抠头发(CS6中调整边缘功能,CC2017中更名为选择并遮住) - - - - - - ...

  3. sql中update,alter,modify,delete,drop的区别和使用(整理)

    关于update和alter: 百度知道上关于update和alter有一个很形象的总结: 一个表有很多字段,一个字段里有很多数据. 一个家有很多房间,一个房间里有很多家具. update是用来将衣柜 ...

  4. C# mvc统一通道使用过滤器

    问题描述 使用C#过滤器有一个最大的问题就是在过滤器转向后程序仍然会执行方法体 问题解决思路 使用统一通道执行方法 不直接进入控制器 通过反射调用 using System; using System ...

  5. .net面试中的一些常见问题与答案

    1.页面传值的方式及其优缺点?   Session,Application,Cookies,Requst.QueryString,Requst.Form,Server.Transfer(通过Conte ...

  6. Repository、IUnitOfWork 和 IDbContext

    1)领域层不应该直接依赖于仓储实现:如果领域层依赖于仓储实现,一是技术绑定太紧密,二是仓储要对领域对象作操作,会造成循环依赖. 2)将接口定义在领域层,减少技术架构依赖,应用层或领域层要使用某个仓储实 ...

  7. JAVASCRIPT中{} + {}的结果是什么?

    转自:http://www.heyria.com/index.php/2014/01/js-object-plus-object/ 当对象或者数组相加的时候,会产生有点意外的结果. 这篇文章主要是解释 ...

  8. Atitit. 木马病毒的外部class自动加载机制------加载class的方法总结

    Atitit. 木马病毒的外部class自动加载机制------加载class的方法总结 Atitit.java load class methods 1. 动态加载jar文件和class文件. 1 ...

  9. Html打印需要内容块(Js实现)

    首先在head里面加入下面一段js代码: function preview(oper) { ) { bdhtml = window.document.body.innerHTML; //获取当前页的h ...

  10. Android JNI和NDK学习(01)--搭建NDK开发环境(转)

    本文转自:http://www.cnblogs.com/skywang12345/archive/2013/05/23/3095013.html 本文主要介绍“JNI”.“Android NDK”以及 ...