[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2273
  • Last Modified:

HashMap and WebServices-- URGENT!!!!

Hello Experts,

I am using JAX-WS and Java2Wsdl to generate the wsdl. The generated  WSDL has to be used by both Java and .Net clients. The interface method that I have looks like this

public interface IEmployessService {
public HashMap<String, String> getEmployeeInfo(@WebParam(name = "empId") String empId) throws Exception;

When I run Java2Wsdl using this, the generated wsdl has a HashMap as the return type. As I would like my webservice to be consumed by all clients, I would like it to be as generic as possible. So I would not like to use HashMap as the return type. So my question is:-

What is the best way to represent a HashMap in a WebService?
1 Solution
Hi gbvreddy,

There is no data type that can represent HashMap for both Java and .Net.

I suggest you to use String data type with pre-define a specific format to represneht HashMap such as


Hope this help,
Gurvinder Pal SinghCommented:
You should not be using collections like (maps, sets, lists etc) for a web-services.
1) Both the sides may not be supporting these types
2) web-service is meant to make client and server agnostic of technology, like C++ could be the client for a .net service
3) WSDL standard 1.1 doesn't support it

gbvreddyAuthor Commented:
-Thanks sompol,
How do I represent it in the wsdl?

- Thanks Gurivender for the sugesstions...

Its type in wsdl will be string which we can make sure that all platforms will support.

So it will represent in wsdl as string type.

But the format or separator is the thing that you have to define and agree with other system that you communicate with.

Hope this help,
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
HashMap is not inter operable, but the one JAXWS generates is a XML Map kind of structure which is interoperable, unlike the JAX-RPC. Give it a  try it will work fine, We have tried this before.

All the best let me know if you face any issues, also provide the WSDL which is generated in case of issue.

Featured Post

Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now