Hi Stephan, Thanks for your quick answer ... I just thought about this fix this morning, 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: ksoap-admin@enhydra.org [mailto:ksoap-admin@enhydra.org] On Behalf Of Stefan Haustein Sent: mardi 10 février 2004 01:33 To: ksoap@enhydra.org Subject: Re: Ksoap: classToQName mapping Hi Simon, The problem is the difference between the class representing the primitive java type "int" and the corresponding box(?) class Integer. The box class simply encapsulates a primitive type in an object, making it storable in vectors and hashtables. KSoap always uses the boxing class. Probably your fix only works because the name matches the XML Schema type name by inclident. I think this should better be fixed in the method lookup routine by adding "something" that converts the java Class instances for primitive types to their boxing class... Something like public Class getBoxClass(Class c) { if (c == Integer.TYPE) return Integer.class; if (c == 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 side. :) I mainly implemented the server stuff to be able to provide a server endpoint for participating in SOAP testing... Best, Stefan Simon Bretin wrote: > Hello KSoap Users, > > I just started using the kSoap engine as a Web Services Server, the client > being Excel and the MS SOAP Toolkit 3.0. > > 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 classMap > parameters, we deduct the type of the argument that needs to be following > that. However the type is something like (Class)int, but the mapping in the > classToQName hashMap is on java.lang.Integer. not int ! > > 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 */ > > public void addMapping (String namespace, String name, > Class clazz, Marshal marshal) { > > qNameToClass.put (new SoapPrimitive (namespace, name, null), > marshal == null ? (Object) clazz : marshal); > > classToQName.put (clazz.getName (), > new Object [] {namespace, name, null, marshal}); > > classToQName.put (name, > new Object [] {namespace, name, null, marshal}); > > > if (prefixMap.getPrefix (namespace) == null) > prefixMap = new PrefixMap (prefixMap, "n"+(cnt++), namespace); > } > > > Does this sounds familiar to you guys . Or did I make some mistake somewhere > when invoking my web service server ? > > Thanks a lot for the help, > > Simon > > _______________________________________________ > Ksoap mailing list > Ksoap@enhydra.org > http://www.enhydra.org/mailman/listinfo.cgi/ksoap _______________________________________________ Ksoap mailing list Ksoap@enhydra.org http://www.enhydra.org/mailman/listinfo.cgi/ksoap |