Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hashtables in WSDL  RSS feed

 
Pratul Chakre
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a WebService operation that takes a JavaBean (A) as input parameter. It returns another JavaBean (C) that contains a Hashtable and a third JavaBean (B).

I have two problems employing this:

a) When I created the WSDL for the above operation, the Hashtable got converted to 'Map' (I did not find any XSD for Hashtable). Could somebody please let me know how to declare Hashtables to be used in WSDL?

b) I need to set the key of the Hashtable as one of the user Defined JavaBeans (complex-type). However, doing so and I am not able to retrieve the value on the client side. If I set the key as a Java primitive type (string), then all works well. Would somebody please explain why this would happen?

Can somebody help me out? If required, i can post teh sample code here as well.

Thanks in advance.

Regards,
Pratul Chakre
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See How to use List and HashMap as parameters to a web service? for suggestions.
 
Pratul Chakre
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peer,

Thanks a lot for your response.

However, my requirement is to send error messages specific to a field on the front-end (client), so that they can be displayed directly in front of the erroneous fields. As a result, the error messages need to be tied to an ID (which is the field name) and hence, the use of Hashtable/Hashmap.

In this case, an array of Strings woudl not help as then it would not have any links to the specific fields to which a message belongs to.

Could you please suggest?

Thanks,
Pratul Chakre
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pratul Chakre:
As a result, the error messages need to be tied to an ID (which is the field name) and hence, the use of Hashtable/Hashmap.


Option 1: Send an XML fragment along the lines of



If you want to save yourself some work, design the XML schema first, include it in your WSDL and then use WSDL2Java to generate the server and client stubs. The equivalent (mapped) Java class/data type for "error" will be in there. Then on the client side iterate through the mapped Java "errors" collection/array to load your Hashtable/HashMap.

Option 2: This is a kludge. Send two arrays: one with the IDs, the other with the messages - one linked to the other via the same array index. On the client side iterate through the arrays simultaneously to load your Hashtable/HashMap.
 
Pratul Chakre
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Peer ! Option A is what I would be working on.

Thank you once again.

Regards,
Pratul Chakre
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!