Axis2复杂类型的问题,急

superxiaomm 2007-08-27 09:15:57
环境:jdk1.5 / Euro Eclipse / apache axis2.1.2
情况:在webservice端,我需要将一个list数组传到客户端。在webservice端,选用pojo方式。
在client端,用wsdl2java产生stub和proxy代码xxxSOAP11Port_httpStub 和 xxxSOAP11Port_httpCallbackHandler两个文件

问题:list数组传不过来,一直会有axis2的exception
求教
...全文
937 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
diggywang 2007-08-30
  • 打赏
  • 举报
回复
Object[] response = serviceClient.invokeBlocking(opGetWeather,
opGetWeatherArgs, returnTypes);

这个object数组都让你拿到了,怎么还会有问题呢?
》》我必须得知传出来的数组的大小才可以,就意味着我要调用一个额外的方法?

response得到后,要知道数组大小,用response.length()不就行了?
superxiaomm 2007-08-29
  • 打赏
  • 举报
回复
help,就卡在这里了
diggywang 2007-08-28
  • 打赏
  • 举报
回复
客户端得到的时候使用iterator
yj_askyaya 2007-08-28
  • 打赏
  • 举报
回复
不错,可以考虑
superxiaomm 2007-08-28
  • 打赏
  • 举报
回复
能不能给个例子啊。现在我遇到的问题是:
soap信息对了:
如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:browseBooksResponse xmlns:ns="http://impl.webservice.bookstore.hslcn.com/xsd">
<ns:return>
<author xmlns="http://helper.bookstore.hslcn.com/xsd">George</author>
<bookId xmlns="http://helper.bookstore.hslcn.com/xsd">46</bookId>
<bookNumber xmlns="http://helper.bookstore.hslcn.com/xsd">5</bookNumber>
<description xmlns="http://helper.bookstore.hslcn.com/xsd">Give you a brief introduction of Sql Server</description>
<discount xmlns="http://helper.bookstore.hslcn.com/xsd">3</discount>
<isbn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://helper.bookstore.hslcn.com/xsd" xsi:nil="true"/>
<name xmlns="http://helper.bookstore.hslcn.com/xsd">sqlserver</name>
<price xmlns="http://helper.bookstore.hslcn.com/xsd">13.0</price>
<publishDate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://helper.bookstore.hslcn.com/xsd" xsi:nil="true"/>
<saleDate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://helper.bookstore.hslcn.com/xsd" xsi:nil="true"/>
<typeId xmlns="http://helper.bookstore.hslcn.com/xsd">1</typeId>
</ns:return>
<ns:return>
<author xmlns="http://helper.bookstore.hslcn.com/xsd">Aguastaus</author>
<bookId xmlns="http://helper.bookstore.hslcn.com/xsd">64</bookId>
<bookNumber xmlns="http://helper.bookstore.hslcn.com/xsd">5</bookNumber>
<description xmlns="http://helper.bookstore.hslcn.com/xsd">Make you overnight millionare</description>
<discount xmlns="http://helper.bookstore.hslcn.com/xsd">3</discount>
<isbn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://helper.bookstore.hslcn.com/xsd" xsi:nil="true"/>
<name xmlns="http://helper.bookstore.hslcn.com/xsd">Stocks</name>
<price xmlns="http://helper.bookstore.hslcn.com/xsd">12.0</price>
<publishDate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://helper.bookstore.hslcn.com/xsd" xsi:nil="true"/>
<saleDate xmlns="http://helper.bookstore.hslcn.com/xsd">2007-05-22T16:00:00.000Z</saleDate>
<typeId xmlns="http://helper.bookstore.hslcn.com/xsd">3</typeId>
</ns:return>
</ns:browseBooksResponse>
</soapenv:Body>
</soapenv:Envelope>


在wsdl2java给我的code里面,准备要改写
我有org.apache.axiom.soap.SOAPBody body = _returnEnv.getBody();
我想要通过OMElement那套东西自己解析出来,比如有几个return,绑定到对象中,具体怎么做??谢谢
diggywang 2007-08-27
  • 打赏
  • 举报
回复
肯定是可以传的,不过最后客户端解析出来的不是list而是数组。
楼主的问题说明太简单,最好更详细点。
包括服务端的service代码和客户端的调用代码,以及axis2的异常都要贴出来!
superxiaomm 2007-08-27
  • 打赏
  • 举报
回复
我查了下,主要还是axis2传输list类型,有人会嘛??
superxiaomm 2007-08-27
  • 打赏
  • 举报
回复
有人help嘛??
superxiaomm 2007-08-27
  • 打赏
  • 举报
回复
续上:
发现调用方法, client端
Class[] returnTypes = new Class[2];
for(int i=0;i<2;i++)
{
returnTypes[i] = Order.class;
}

Object[] response = serviceClient.invokeBlocking(opGetWeather,
opGetWeatherArgs, returnTypes);

Order result = (Order) response[0];
Order result2 = (Order) response[1];
主要是class这里,要写多个好像。
但是我有个问题,这样的话,我必须得知传出来的数组的大小才可以,就意味着我要调用一个额外的方法(webservice),有没有可以一次性解决的方法嘛????
superxiaomm 2007-08-27
  • 打赏
  • 举报
回复
我找到一个方法,是这样的
传输的Bean : Order 已经可序列化
Service 方法:
public Order[] getOrder()
{
Order[] list = new Order[2];

Order or = new Order();
or.setOrderId(1);
or.setName("jacob");
or.setDescription("jabob's order");

list[0] = or;

Order or2 =new Order();
or2.setOrderId(2);
or2.setName("abc");
or2.setDescription("abc's order");

list[1] = or2;
return list;
}
部署文件 没有什么特别 :
<service name="OrderService" >
<description>
Please Type your service description here
</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass" locked="false">com.jacob.Service.OrderService</parameter>
</service>

67,513

社区成员

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

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