Axis2Service客户端访问通用类集合List自定义类型
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自定义类型的更多相关文章
- C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]
原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...
- C#---数据库访问通用类、Access数据库操作类、mysql类 .
//C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using System. ...
- [c#基础]泛型集合的自定义类型排序
引用 最近总有种感觉,自己复习的进度总被项目中的问题给耽搁了,项目中遇到的问题,不总结又不行,只能将复习基础方面的东西放后再放后.一直没研究过太深奥的东西,过去一年一直在基础上打转,写代码,反编译,不 ...
- C# 泛型集合的自定义类型排序
一.泛型集合List<T>排序 经sort方法之后,采用了升序的方式进行排列的. List<int> list = new List<int>() { 2, 4, ...
- HashSet存储自定义类型元素和LinkedHashSet集合
HashSet集合存储自定义类型元素 HashSet存储自定义类型元素 set集合报错元素唯一: ~存储的元素(String,Integer,-Student,Person-)必须重写hashCode ...
- [转]DbHelper通用数据库访问帮助类
之前我一直都是在博客园中查看各位高手的博文,确实学到了不少知识,不过比较少写博客,现在就把我自己在项目实施过程中使用到比较好的技术框架写出来,希望能让更多的人了解和学习. 通常我们在开发使用数据库访问 ...
- sharepoint 2010自定义访问日志列表设置移动终端否和客户端访问系统等计算列的公式
上个月本人开发和上线了一个在SharePoint 2010上基于HTML5的移动OA网站,后端服务采用自定义的基于AgilePoint工作流引擎的Sharepoint Web服务,前端主要采用Jque ...
- java数据类型:集合存储元素类型限制<泛型> ;自定义类指定泛型<T> 以及限制用法;派生子类泛型<T> super(泛型内参数); 泛型通配符?以及?限制用法
问题背景 Java 集合有个缺点,把一个对象"丢进"集合里之后,集合就会"忘记"这个对象的数据类型,当再次取出该对象时 该对象的编译类型就变Object类型(其 ...
- NPOI MVC 模型导出Excel通用类
通用类: public enum DataTypeEnum { Int = , Float = , Double = , String = , DateTime = , Date = } public ...
随机推荐
- 金典 SQL笔记(2)
由于在本地笔记上写的.CSDN markdown编辑器仅仅支持.md格式导入, 图片没办法直接导进去.写的多了懒的一张一张图片切图上传; 直接整个文章切成图片上传上去了.
- 【Java】Java_11运算符
1.运算符(operator) Java 语言支持如下运算符: 算术运算符: +,-,*,/,%,++ 赋值运算符 = 关系运算符: >,<,>=,<=,==,!= i ...
- asp.net+mvc+easyui+sqlite 简单用户系统学习之旅(四)—— session传递登录人信息显示+用户注销
前面的学习,已经做好了简单的登录和主页,涉及了三层软件架构,mvc,easyui的layout.tree.tab.window,sqlite,动软代码自动生成. 下面完善一下登录跳转主页后,在sout ...
- Atitit.变量的定义 获取 储存 物理结构 基本类型简化 隐式转换 类型推导 与底层原理 attilaxDSL
Atitit.变量的定义 获取 储存 物理结构 基本类型简化 隐式转换 类型推导 与底层原理 attilaxDSL 1.1. $ 美元字符, php 黑头1 1.2. 默认变量的范围和声明:1 1.3 ...
- python-class(5)
#!/usr/bin/env python #-*- coding:utf-8 -*- ############################ #File Name: class5.py #Auth ...
- grub手动引导win7
grub>rootnoverify (hd0,0)--->win7系统安装盘号 grub > chainloader +1 grub > makeactive ---& ...
- wb标准
1. WEB标准 WEB标准不是某一个标准,而是一系列标准的集合.网页主要由三部分组成:结构(Structure).表现(Presentation)和行为(Behavior).对应的标准也分三方面:结 ...
- C++之类的静态成员变量和静态成员函数
static静态成员函数 在类中.static 除了声明静态成员变量,还能够声明静态成员函数. 普通成员函数能够訪问全部成员变量.而静态成员函数仅仅能訪问静态成员变量. 我们知道.当调用一个对象的成员 ...
- Java并发计数器探秘
前言 一提到线程安全的并发计数器,AtomicLong 必然是第一个被联想到的工具.Atomic* 一系列的原子类以及它们背后的 CAS 无锁算法,常常是高性能,高并发的代名词.本文将会阐释,在并发场 ...
- go的sync.Map
sync.Map这个数据结构是线程安全的(基本类型Map结构体在并发读写时会panic严重错误),它填补了Map线程不安全的缺陷,不过最好只在需要的情况下使用.它一般用于并发模型中对同一类map结构体 ...