webservice返回List如何解析

zhanlaohu 2008-09-08 11:32:32
我用AXIS2做了一个服务,用AXIS2客户API调用它
public class Main {
public OMElement createPayLoad(){
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://service.test.com", "ns1");
OMElement method = fac.createOMElement("getWxpBaseList",omNs);
OMElement value = fac.createOMElement("hpzl", omNs);
value.setText("01");
OMElement value2 = fac.createOMElement("hphm", omNs);
value2.setText("皖A21763");
method.addChild(value);
method.addChild(value2);
return method;
}

public static void main(String[] args) throws Exception{
ServiceClient serviceClient = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference("http://localhost:8080/WxpService/services/WxpTransService"));
opts.setAction("urn:getWxpBaseList");
serviceClient.setOptions(opts);
OMElement res = serviceClient.sendReceive(new Main().createPayLoad());//blocking method
System.out.println(res);
}

}
输出的结果如下:
<ns:getWxpBaseListResponse xmlns:ns="http://service.keli.com">
<ns:return xmlns:ax22="http://objwxp.db.keli.com/xsd" xmlns:ax21="http://res.keli.com/xsd" type="com.keli.res.WxpBaseResult">

<ax21:objList type="com.keli.db.objwxp.WxpBaseInfor" >
<ax22:hphm>皖A21763</ax22:hphm>
<ax22:hpzl>01</ax22:hpzl>
<ax22:hpzl_V>大型汽车</ax22:hpzl_V>
</ax21:objList>

<ax21:obj xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
</ns:return>
</ns:getWxpBaseListResponse>
请问返回是个List,我该如何解析它,并把它封装成type所指定的类型
...全文
687 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Defonds 2008-09-19
  • 打赏
  • 举报
回复
mark
lyboyc 2008-09-19
  • 打赏
  • 举报
回复
一个方法是list加个头,封装成xml,通过dom4j什么的解析xml
WHW1984 2008-09-19
  • 打赏
  • 举报
回复
查下OMElement下是否有getlist的函数!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧