How to transfer a java.util.Map through a Web Service?
Asked Answered
B

2

6

My method returns a Map<Integer, String[]>. Is it possible to pass it through to a Web Service?

Bohman answered 12/10, 2011 at 9:26 Comment(1)
Is the key really an int? Isn't it actually an Integer?Thamos
U
3

It's best not to expose a Java collections through your web service interface.

You should expose only simple types, beans and arrays instead, or you risk getting into trouble (interoperability kind of trouble).

Try converting your Map into an array, like for example an array of Map.Entrys or something wrapping those entries.

Uticas answered 12/10, 2011 at 20:44 Comment(0)
A
3

Map is specific to java..

You can use only arrays, int, string.. everything that is common in all the other languages that can use webservices (PHP, C#, C++, etc)... And think about it... what is the Map in PHP? there is not... webservices are built to share data in more than one language...

If you want to use it with Map and you are using this application only for java you'd better use RMI and not WebServices

Advertent answered 14/10, 2011 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.