RE: classToQName mapping

"Simon Bretin" <[email protected]> Tue, 10 Feb 2004 07:44:38 +0100
Newsgroups gmane.comp.java.enhydra.ksoap
Organization Anyware Technologies
Message-ID <[email protected]>
Hi Stephan,

Thanks for your quick answer ... I just thought about this fix this morni=
ng,
and I think you are totally right ... I will make this change and maybe
submit the change on this list for integration in the code source !

Glad to hear that I'm the first one to try KSoap server functionalities .=
..
If you want I may publish more examples of server like the ones I'm
currently working on !

Simon

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf =
Of
Stefan Haustein
Sent: mardi 10 f=E9vrier 2004 01:33
To: [email protected]
Subject: Re: Ksoap: classToQName mapping

Hi Simon,

The problem is the difference between the class representing the primitiv=
e
java=20
type "int" and the corresponding box(?) class Integer. The box class simp=
ly=20
encapsulates a primitive type in an object, making it storable in vectors
and=20
hashtables. KSoap always uses the boxing class. Probably your fix only wo=
rks

because the name matches the XML Schema type name by inclident.

I think this should better be fixed in the method lookup routine by addin=
g=20
"something" that converts the java Class instances for primitive types to
their=20
boxing class...

Something like

public Class getBoxClass(Class c) {
   if (c =3D=3D Integer.TYPE) return Integer.class;
   if (c =3D=3D Long.TYPE) return Long.class;
   //...
   return c;
}

-- called for all the parameter types of a method when a method is
registered.

I must admit that I did not expect anybody to actually use kSOAP on the
server=20
side. :) I mainly implemented the server stuff to be able to provide a
server=20
endpoint for participating in SOAP testing...

Best,
Stefan



Simon Bretin wrote:
> Hello KSoap Users,
>=20
> I just started using the kSoap engine as a Web Services Server, the cli=
ent
> being Excel and the MS SOAP Toolkit 3.0.
>=20
> I had problems passing int parameters from Excel to the kSoap server.
Every
> time I had an invocation target exception because the types where
incorrect.
> Indeed the types and args parameters of the SoapReq where not of type
> (Class)int but rather AnyType or something like it.
> I discovered what might be the cause of the problem, down inside the
> ClassMap. When we parse the SOAP request, we look for the for the name =
of
> the method we want to call. With the next argument, and from the classM=
ap
> parameters, we deduct the type of the argument that needs to be followi=
ng
> that. However the type is something like (Class)int, but the mapping in
the
> classToQName hashMap is on java.lang.Integer. not int !
>=20
> I had to modify the classMap::addMapping function to have the following=
 :
>     /** Defines a direct mapping from a namespace and name to a java
>         class (and vice versa), using the given marshal mechanism */
>=20
>     public void addMapping (String namespace, String name,=20
> 			    Class clazz, Marshal marshal) {
>=20
> 	qNameToClass.put (new SoapPrimitive (namespace, name, null),=20
> 			  marshal =3D=3D null ? (Object) clazz : marshal);
>=20
> 	classToQName.put (clazz.getName (),=20
> 			  new Object [] {namespace, name, null, marshal});
>=20
> 	classToQName.put (name,=20
> 			new Object [] {namespace, name, null, marshal});
>=20
> 			 =20
> 	if (prefixMap.getPrefix (namespace) =3D=3D null)=20
> 	    prefixMap =3D new PrefixMap (prefixMap, "n"+(cnt++), namespace);
>     }
>=20
>=20
> Does this sounds familiar to you guys . Or did I make some mistake
somewhere
> when invoking my web service server ?
>=20
> Thanks a lot for the help,
>=20
> Simon
>=20
> _______________________________________________
> Ksoap mailing list
> [email protected]
> http://www.enhydra.org/mailman/listinfo.cgi/ksoap



_______________________________________________
Ksoap mailing list
[email protected]
http://www.enhydra.org/mailman/listinfo.cgi/ksoap