Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Hashtables in WSDL

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic