• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Can we support Map/HashMap in the webservice as one of internal parameters?

 
Greenhorn
Posts: 15
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have written a simple webservice. Which just prints the content of the input.

And


I am using Eclipse Java EE IDE for Web Developers.(Version: Helios Service Release 1) for generating stubs like this :
New wizard , webservice, Selecting the server runtime (tomcat 6) and webruntime as Axis2. And clicking finish.

It generates the project with name TestClient. And inside that 2 classes : ServiceClassCallbackHandler and ServiceClassStub.

Once WebService is generated its also opening one JSP (WebService explorer) . In that I can see the WebService and clicking on basicwebservice it shows UI where I can input my data.

But its not showing if I can add key/value for map.

I am not sure how to test this?
More importantly can I test my webservice that it prints the passed data?
How to pass the test data to this webservice?
Or how to pass MyVO object to the webservice?

Thanks in advance.

 
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!
Generally, it is considered a bad idea to use Java collection classes as parameter or result types of methods that are to be exposed as web service operations.
A suggestion, in your case, may be to store key-value pairs from the map in an array of arrays, where each row contains two elements, a key and a pair.
I am not sure about the specific case of Axis, though - there may be some mechanism that can cope with Java collection classes.
Best wishes!
 
Arpan Raj
Greenhorn
Posts: 15
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ivan.
I agree that we should avoid sending collections over the wire but here requirement is such that i cannot avoid .

I tried writing the wsdl first and generate the stubs/skeleton but i am not able to generate in the eclipse.
I tried generated the stubs/skeleton using wsdl2java but it gives the compilation issues.
I am stuck badly in this.

I am sharing WSDL here. Can you pl. suggest if I am missing something?

Thanks in advance.

 
Ivan Krizsan
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!
As before, I have little experience with Axis. However, a quick search on the internet reveals this:
http://mail-archives.apache.org/mod_mbox/cxf-users/200809.mbox/%[email protected]%3E
It seems like the Map type is rather old and also uses SOAP encoding.
Best wishes!
 
Arpan Raj
Greenhorn
Posts: 15
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ivan.

I checked on the link. I am using the map in the same way in the xsd declaration.
I am able to generate the skeleton successfully.
But I've an issue with passing the value.
It generates its own map implementation and that map has Map Element entry.
Now This entry has two methods of our use to set entry's value
i.e. SetKey and SetValue in both of these generated method it takes OMElement as parameter.


And this key is of type OMElement interface I am not sure how to set this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic