`
xurichusheng
  • 浏览: 335223 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

webservice入参和输出都是复杂对象

 
阅读更多

 

环境:xfire 1.2.6

 

1. 接口

  

    接口的返回值原先是用 Map<String, MeasureTypeVO>的,但是好像 xfire 的返回值不支持复杂的对象,

所以改成将 Map<String, MeasureTypeVO> 设置成对象 MeasureTypeDTO 的一个属性

   

public MeasureTypeDTO getMeasureTypes(String reqSeq, List<String> cimIdList)
			throws Exception;

 

 

2. 接口.aegis.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<mappings>
	<mapping>
		<method name="getMeasureTypes">
			<parameter index="0" mappedName="reqSeq" />
			<parameter index="1" mappedName="cimIdList" componentType="java.lang.String" />
			<return-type componentType="com.techstar.plat.webservice.dto.MeasureTypeDTO" />
		</method>
	</mapping>
</mappings>

 

 

    由于接口的第二个参数是个 List ,所以在第二个<parameter>中需要写上

     componentType="List泛型中的对象",如 componentType="java.lang.String"

 

3. 实现方法

public MeasureTypeDTO getMeasureTypes(String reqSeq, List<String> cimIdList)
		throws Exception {

	Map<String, MeasureTypeVO> map = MeasureTypeService.getInstance()
			.getMeasureTypes(cimIdList);

	MeasureTypeDTO dto = new MeasureTypeDTO();

	dto.setMap(map);

	return dto;
}

 

 

4. dto 类 MeasureTypeDTO

 

public class MeasureTypeDTO {

	private Map<String, MeasureTypeVO> map;

	public Map<String, MeasureTypeVO> getMap() {
		return map;
	}

	public void setMap(Map<String, MeasureTypeVO> map) {
		this.map = map;
	}
}

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics