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.
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.
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.