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. Python——调用shell命令的三种方法

    1.用os.system(cmd)   不过取不了返回值 2.用os.popen(cmd)   要得到命令的输出内容,只需再调用下read()或readlines()等 如a=os.popen(cmd ...

  2. POJ1088 动态规划

    题意: id=1088">题目链接 解答: 这个题目和最长子序列什么的极为类似.只是之前都是一维,如今变成二维的了.仅此而已.因此我们能够想办法把它先变成一维的. 先用一个结构体存储这 ...

  3. nnlog-yaml

    from nnlog import Logger# log=Logger(file_name='my.log',level='debug',# when='S',backCount=5,interva ...

  4. 递归 recursive

    递归函数是在一个函数通过名字调用自身的情况下构成的. function factorail(num) { if(num <= 1) { return 1; } else{ return num ...

  5. 在php中修改cookie值遇到的奇怪问题

    本想修改cookie的值比较简单,结果测试发现并不是. 刚开始实现cookie修改的思路:先删除以前的cookie值,再创建一个新的. setcookie('name',value,time()-1) ...

  6. GuozhongCrawler系列教程 (2) CrawTaskBuilder具体解释

    GuozhongCrawler是分层架构.要高速学习CrawlTask独立的配置多少要了解框架的源码.所以CrawTaskBuilder提供要更加扁平且易于理解的的方式创建CrawTask 方法具体资 ...

  7. Hyperlynx仿真学习

    转: 1.Hyperlynx 仿真模型讲解 2.Hyperlynx使用心得 3.https://blog.csdn.net/xyh627733894/article/details/78526725 ...

  8. webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc ((); 或者 Unexpected token: operator (>)

    webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc (();  或者 Unexpected token: operator (>) 解决方案 ...

  9. 第八章 springboot + mybatis + 多数据源3(使用切面AOP)

    引入 aop包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  10. mock带参数的构造函数

    @RunWith(PowerMockRunner.class)@PrepareForTest(Helper.class)//1.添加要初始化的类,就是构造函数所在的类public class Help ...