Re: HttpTransport of a VECTOR to a Apache-Axis Webservice

[email protected] Fri, 25 Apr 2003 10:08:02 +0200
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
Hi,

In fact, you can serialize a "Vector" (at least using KSoap 1.x).

Here is a code snippet demonstrating this :

<snip>

// here we fill the vector with complex objects
Vector soapModuleReferences = new Vector();
for (int i = 0; i < moduleReferences.length; i++)
{
        ModuleReference moduleReference = moduleReferences[i];
        SoapObject o = new SoapObject("http://myNS", "ModuleReference");
        o.addProperty("date", moduleReference.getDate());
        o.addProperty("id", moduleReference.getId());
        o.addProperty("version", moduleReference.getVersion());
        soapModuleReferences.add(o);
}

SoapObject rpc = new SoapObject("http://myNS", "getModuleUpdates");
// here we add the vector : Note that you can provide extra parameters to 
define the use of references and declare the type of the elements in the 
vector
rpc.addProperty(new PropertyInfo("moduleReferences", 
PropertyInfo.VECTOR_CLASS, false, new ElementType(ModuleReference.class)), 
soapModuleReferences);

</snip>

Hope it helps !

Regards,

----------------------------------------------------------------------------
Sebastien Petrucci
Java Technology Consultant - Altran Europe
Philips Remote Control Systems
Interleuvenlaan 74-76, B-3001 Leuven (Belgium)
M +32(0)497502521    T  +32(0)16394 598
----------------------------------------------------------------------------









Michael Yuan <[email protected]>
Sent by: 
[email protected]
2003-04-24 19:33
Please respond to ksoap

 
        To:     [email protected]
        cc:     (bcc: Sebastien Petrucci/LEU/COMP/PHILIPS)
        Subject:        Re: Ksoap:  HttpTransport of a VECTOR to a Apache-Axis Webservice
        Classification: 




You cannot serialize a "Vector" object. Try an array of Strings. in kSOAP
String [] is mapped to Vector.

cheers
Michael
--------------------
Michael Yuan's Book, Articles and Blog
http://www.enterprisej2me.com

On Thu, 24 Apr 2003, Thomas Sillhengst wrote:

> Hi,
> 
> I would like to transmit a Vector to a Axis-WebService with kSOAP.
> But I get the error message: Could not serialize: @vector
> Sending a normal String has already worked, but I cannot serialize a
> vector object.
> 
> Source of the Client:
> 
>         Vector Vectorname = new Vector();
>         Vector.addElement("test1"); Vector.addElement("test2");
> 
>         SoapObject rpc = new SoapObject
> ("http://xml.apache.org/xml-soap", "getProfile");
> 
>        PropertyInfo p = new
> PropertyInfo("tempVector",Vectorname,true,ElementType.VECTOR_CLASS);
> 
> 
>         rpc.addProperty(p,Vectorname);
> 
>         ht = new
> HttpTransport("http://localhost:8080/Axis/services/userprofile", "");
> 
>          ClassMap classMap = new ClassMap ();
>          ht.setClassMap (classMap);
>          String st = (ht.call(rpc)).toString();
> 
> Signature of the WebService methode:
> 
>           public boolean getProfile(Vector tempVector) 
> 
> 
> Whats wrong with my source-code?
> If the serialization of an object (Vector) isn't possible, whitch ohter
> possibilities do I have?
> Are there incompatibilities between the java Vector and the SOAP Vector?
> 
> Ciao
> Thomas
> 
> 

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