如何从Web服务返回自定义对象的数组列表?
如何从 Web 服务获取自定义对象的数组列表?
我定义了一个返回如下列表的方法:ArrayList
但是在客户端 ws 中,我收到一个对象的 ArrayList...
看来我无法通过将自定义类复制到小程序的客户端 jar 文件来转换它,就像序列化对象一样...
我该怎么办?
How can i get array list of custom object from web service?
I define a method that returns a list like this : ArrayList<Car> getVehicle() {...}
But in client ws, I receive an ArrayList of objects...
It seems I can't cast it even by copying custom class to client jar file of my applet, like serialized object...
How can i do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看来你必须在 webservice 的客户端将对象转换为 arraylist 。您是否在 .wsdl 文件中验证了您提到的 Web 服务方法的正确返回类型?
如果您已经解决了这个问题,请发布解决方案。
It seems that you have to cast objects in arraylist at webservice's client end. Did you verify that in .wsdl file you mention proper return type of webservice method?
please publish the solution if you already solved this issue.
同样的annotationfree,即使没有annotation也可以获取元素
Likewise annotationfree, you can get element even no annotation
只需使用 ArrayList 的 toArray() 方法将 ArrayList 转换为 Object[] 即可解决此问题,它将转换为 Object[] 并可以用作 bject[] getVehicle() {...} 在您调用它的地方遍历他的数组并转换为 Car 对象。
It can be solved by just converting the ArrayList into Object[] by using ArrayList's toArray() method it will convert into Object[] and it can be used as bject[] getVehicle() {...} where you call it traverse his array and cast into Car object.
这是一个选项吗:
它会改变什么吗?
Is this an option:
Does it change anything?