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. ant-design table 分页(tableProps)

    1.布局 <Table dataSource={this.state.tableDetailList} scroll={{ y: '200px' }} style={{tableLayout: ...

  2. python中MySQL模块TypeError: %d format: a number is required, not str异常解决

    转载自:http://www.codeif.com/topic/896 python代码: attr_sql = "INSERT INTO `ym_attribute` (`attr_nam ...

  3. struts提交action乱码

    没下雪但冷的让人直打哆嗦的天气,冷醉了的教训!!   问题解决步骤: 1.首先确认页面编码是否准确,并且是否与struts编码配置一样,就算是gbk对GBK,最好大小写保持一样 2.尝试先转码一次吧! ...

  4. 将DataSet转换成json

     /// <summary>        /// 把dataset数据转换成json的格式        /// </summary>        /// <para ...

  5. VB的第一个项目

     前言-----本人也是刚刚接触VB,企业的VB代码基本能看的懂,但是自己开发,只能呵呵.一般在刚学习一门新的语言时,很容易发生一些自己相当然的认识错误,so,记下并分享开发学习的过程,望指正.--- ...

  6. tcp/ip ---IP路由选择

    从概念上说, I P路由选择是简单的,特别对于主机来说.如果目的主机与源主机直接相连(如点对点链路)或都在一个共享网络上(以太网或令牌环网),那么I P数据报就直接送到目的主机上.否则,主机把数据报发 ...

  7. eclipse日志

    注意包别引入错: import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static final Logger log = ...

  8. SQLServer跨库查询--分布式查询(转载)

    --用openrowset连接远程SQL或插入数据 --如果只是临时访问,可以直接用openrowset --查询示例 select * from openrowset('SQLOLEDB' ,'sq ...

  9. Xcode, does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) 解决办法

    在Build Settings中找到Enable Bitcode项,设置为如下: 参考:http://blog.csdn.net/soindy/article/details/48519363

  10. springboot+thymeleaf打war包在外部tomcat运行

    工程目录 pom文件注意点 <packaging>war</packaging> <dependency> <groupId>org.springfra ...