Hey Keith,
thanks for your opinion. I really appreciate that.
It's absolutely correct what you're saying - do not use language-specific datatypes if you don't want to make other developers
lifes harder.
But in this case: it's an internal service only, so i know for sure that both endpoints are Java. Perhaps "Web Service" is the wrong approach to my problem.
Keith Hatton schrieb:
Hi Mike,
You are right, the Axis WSDL tools will only generate interfaces where the method signatures contain concrete classes.
But using a Map is generally a Bad Idea in SOAP, because it is a language-specific data type (likewise other Java collection things like List and Vector). You may be able to make it work if both client and server are Java, but SOAP is not designed with that goal in mind. You may also wish to consider using a two-dimensional array instead for your key-value pairs.
I am sure if you search the list archives for "WSDL first" you will find plenty of advice suggesting that for best practice with Web Services, you should start with the WSDL and not a Java interface (Java2WSDL and the like are nice "marketing" tools for people to sell you the idea that Web Services are easy and don't involve writing any new code!).
Really, SOAP is just a way of passing messages between systems, not objects. I found the following article on "Web Services misconceptions" useful. http://weblogs.cs.cornell.edu/AllThingsDistributed/archives/000343.html
Of course, you might still have a good reason to use a Map and I wouldn't try to stop you, but I think all us developers often spend effort working on the wrong problems, so just wanted to point out these alternative ideas. Good luck anyway!
Hope this helps Keith
-----Original Message-----
From: Mike Haller [mailto:[EMAIL PROTECTED] Sent: 10 May 2005 11:52
To: [email protected]
Subject: Re: HashMap vs. Map
Thanks for your fast answer Keith.
So, it's not possible to get "clean" generated interfaces? And there is no way to tell Axis to generate interfaces using interfaces and skels/stubs using concrete classes?
It can use whatever Map-implementation it likes to use, as long as the generated interfaces use the Map interface.
Keith Hatton schrieb:
I can answer the first part of your question.
It's using HashMap because Axis cannot instantiate an interface or abstract class. When Axis receives your XML it must build concrete object instances, so it must declare a concrete class. Otherwise which
implementation of Map should it choose?
Hope this helps Keith
-----Original Message----- From: Mike Haller [mailto:[EMAIL PROTECTED] Sent: 10 May 2005 11:00 To: [email protected] Subject: HashMap vs. Map
Hi all,
using Axis 1.2 I'm trying to implement my own service:
public interface MyService {
public org.w3c.dom.Document listObjects(java.util.Map parameters); }
Sadly, the generated code (java2wsdl and then wsdl2java) is generating this interface:
public interface MyService extends java.rmi.Remote { public org.w3c.dom.Document listObjects(java.util.HashMap in0) throws java.rmi.RemoteException; }
Note the difference: Map and HashMap in the method signatures.
Why is it using HashMap instead of Map?
To solve this, i tried to implement my own GeneratorFactory, but failed
to find the location where the mapping is resolved. I also found out that there are <typeMapping> elements - but where do I have to add
them,
since the WSDL file is regenerated on each build.
So, I hope someone can tell me where I can tell Axis' wsdl2java to use Map instead of HashMap.
Thanks, regards Mike
