• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Compile time error in client code for simple example

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am developing simple example which contains HashMap as shown below.
I am using jdk6.



After publishing I generate required artifacts of above class using wsimport.
wsimport -p ch01.misc.wsimport -keep http://localhost:8888/testmap?wsdl

The client code for above example is shown below.



Now the problem is that i am getting compile time error in client code at last line.The method get(String) is undefined for type HashMap .
The code generated by wsimport for HashMap is shown below.




Please help me.

Thanks
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you cannot put any java specific return type on any web service operation, because web sercies are all about interoperability think about some dot net client want to access your web service? they might have diffrent implementation for HashMap or so...
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
The problem is that there is no representation of maps in an XML schema.
You can, however, translate the map to something that can be represented using an array and a POJO.
The array is an array of POJOs an each POJO instance holds a key and a value.
The key and value are of some simple type, like String, Number or similar.

Here is a code example:

Note that this will not readily be transformed to a map, so the client has to have some additional information, apart from the WSDL, as to how to treat this data.
Best wishes!
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic