xml格式
根据会议届次获取普通立案提案(不包括合并提案)
服务名称 | GetLAProposalList | |||
服务说明 | 根据会议届次获取普通立案提案列表(不包括合并提案) | |||
输入值 | <?xml version="1.0" encoding="gb2312" ?> <paras> <meeting>01</meeting>(当前为八届二次会议,对应会议ID为01) (输入的参数是GetMeetingList接口方法中获取到的MeetingID) </paras> | |||
详细参数 | 参数名称 | 参数说明 | 类型 | 是否必填 |
meeting | 会议届次 | 字符型 | 是 | |
返回值 | 返回成功描述 <?xml version=“1.0” encoding="gb2312"?> <EpointDataBody> <DATA> <ReturnInfo> <Status>True</Status> <Description> </Description> </ReturnInfo> </DATA> <UserArea> <ProposalList> <ProposalInfo> <RowGuid>提案Guid(唯一标识)</RowGuid> <ProposalNum>提案编号 </ProposalNum> <Title>提案标题</Title> <Meeting>所属会议</Meeting> <Source>提案类型</Source> <ReceiveDate>收件日期</ReceiveDate> <SubmitGuid>主提者Guid </SubmitGuid> <SubmitNames>主提者姓名 </SubmitNames> <ResolutionerGuids>联名委员Guids </ResolutionerGuids> <Resolutioners>联名委员姓名</Resolutioners> <WriteGuid>执笔人Guid </WriteGuid> <WriteName>执笔人姓名 </WriteName> <ProposalSort>提案小类</ProposalSort> <ProposalBigSort>提案大类</ProposalBigSort> <Suggest_Organizer>建议主办单位</Suggest_Organizer> <Suggest_Co_Organizer>建议协办单位</Suggest_Co_Organizer> <OrganizerGuid>主办单位Guid </OrganizerGuid> <Organizer>主办单位名称 </Organizer> <Co_OrganizerGuids>协办单位Guids </Co_OrganizerGuids> <Co_Organizer>协办单位名称</Co_Organizer> <HandleState>立案状态 </HandleState>(1:立案;2:合并;3:不立案;null或空:暂未审核) <LADate>立案时间 </LADate> <State>提案流转状态</State> <SuperviseUserName>督办领导 </SuperviseUserName> <IS_Excellent>是否优秀提案 </IS_Excellent> <IS_City>是否市政协提案 </IS_City> <Suggestions>提案内容 </Suggestions> <attachfiles> <AttFileURL>提案附件<AttFileURL>(附件路径,可查看下载) </attachfiles> </ProposalInfo> </ProposalList> </UserArea> </EpointDataBody>
返回失败描述: <?xml version=“1.0” encoding="gb2312"?> <EpointDataBody> <DATA> <ReturnInfo> <Status>False</Status> <Description>错误详细信息</Description> </ReturnInfo> </DATA> </EpointDataBody> |
直接获取返回的xml里面包含了太多内容,dom4j取特定节点下我们需要的内容。 public static String getXmlStr(String xml, String targetElementName) throws DocumentException { Document document = DocumentHelper.parseText(xml) ; Element root= document.getRootElement(); String status = root.element("DATA").element("ReturnInfo").element("Status").getText(); String res = ""; if ("True".equals(status)) { Element target = root.element("DATA").element("UserArea").element(targetElementName); res = target.asXML(); } return res; }
调用webService接口并取需要的内容
main() {
HQService hq = new HQService(new URL("http://10.44.106.1/HQWebService/HQService.asmx?WSDL")); HQServiceSoap hqs = hq.getPort(HQServiceSoap.class); String parasXml = "<?xml version='1.0' encoding='gb2312' ?><paras><meeting>83</meeting></paras>"; String res = hqs.getLAProposalList(validateData, parasXml); res = StringUtil.getXmlStr(res, "ProposalList");
}
得到的结果应该是这样的
<ProposalList>
<ProposalInfo>
。。。
</ProposalInfo>
<ProposalInfo>
。。。
</ProposalInfo>
</ProposalList>
xStream用来实现xml和java类的直接转换
看一下实体类
public class ProposalInfo { public String RowGuid; public String ProposalNum; public String Title; 。。。 //省略get set }
public class ProposalInfoList { public List<ProposalInfo> list; public List<ProposalInfo> getList() { return list; } public void setList(List<ProposalInfo> list) { this.list = list; } }
转换方法
public ProposalInfoList getProposals(String xml) { XStream xs = new XStream(new DomDriver()); // 取别名,xml节点名和类对应(类名前带有包名,不然对应不上) xs.alias("ProposalList", ProposalInfoList.class); xs.alias("ProposalInfo", ProposalInfo.class); // addImplicitCollection(Class ownerType, String fieldName),去掉集合类型生成xml的父节点 // 意思是说 ProposalInfoList节点下去掉list节点,直接是ProposalInfo节点 xs.addImplicitCollection(ProposalInfoList.class, "list"); // 告诉XStream要忽略掉未知的XML要素(感觉用处不大) xs.ignoreUnknownElements(); ProposalInfoList xmlp = (ProposalInfoList) xs.fromXML(xml); return xmlp; }
ojbk