KSOAP2 attributes

362 views
Skip to first unread message

João Cruz

unread,
Sep 8, 2011, 1:21:32 PM9/8/11
to ksoap2-...@googlegroups.com
Hi, 

My name is João and i'm working at a project that involves webservices using Android. I'm currently using KSOAP2 for that but i came to a point i don't know what to do:

Is there any way to create a request property with some attributes? I'm able to create a custom property, but don't know how to add the attribute.

Ex:

<PropertyWhatEver>
<MyCustomProperty attr = " something">
<Name> string </Name>
</MyCustomProperty>
</PropertyWhatEver>

How to add the attribute?

Thanks in advance,

Best Regards,

João Cruz

Andrew Oppenlander

unread,
Sep 8, 2011, 1:26:10 PM9/8/11
to ksoap2-...@googlegroups.com
A property refers to a line such as this:
<Name>string</Name>

What you want to do is embed SoapObjects inside of your initial SoapObject.
An example of this can be found here, on the ksoap2-android google code site.
--
Andrew Oppenlander

João Cruz

unread,
Sep 8, 2011, 1:29:40 PM9/8/11
to ksoap2-android
No, i'm talking about adding attribute values to a property. In my
example:

<PropertyWhatEver>
<MyCustomProperty attr = " something"> <--------- attribute
something. want to add this to the "MyCustomProperty".
<Name> string </Name>
</MyCustomProperty>
</PropertyWhatEver>

btw, "MyCustomProperty" extends Kvmserielizable. Only missing the
attribute thing... :(

On Sep 8, 6:26 pm, Andrew Oppenlander <andrew.oppenlan...@gmail.com>
wrote:
> A property refers to a line such as this:
> <Name>string</Name>
>
> What you want to do is embed SoapObjects inside of your initial SoapObject.
> An example of this can be found here, on the ksoap2-android google
> code site<http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#Addi...>
> .

Andrew Oppenlander

unread,
Sep 8, 2011, 1:36:22 PM9/8/11
to ksoap2-...@googlegroups.com
SoapObject propertyWhatEver = new SoapObject(NAMESPACE, "PropertyWhatEver");
SoapObject myCustomProperty = new SoapObject(NAMESPACE, "MyCustomProperty");
myCustomProperty.addAttribute("attr", "something");
myCustomProperty.addProperty("Name", "string");
propertyWhatEver.addSoapObject(myCustomProperty);
--
Andrew Oppenlander

João Cruz

unread,
Sep 12, 2011, 5:52:19 AM9/12/11
to ksoap2-android
Hi again.

That's the problem.. i dont have the method "AddAttribute"
available... and i have the latest ksoap2 library :S

On Sep 8, 6:36 pm, Andrew Oppenlander <andrew.oppenlan...@gmail.com>
wrote:

João Cruz

unread,
Sep 12, 2011, 6:21:23 AM9/12/11
to ksoap2-android
http://ksoap2.sourceforge.net/doc/api/org/ksoap2/serialization/SoapObject.html

As you can see here at the documentation, the method addAttribute is
not defined :S

Andrew Oppenlander

unread,
Sep 12, 2011, 9:09:46 AM9/12/11
to ksoap2-...@googlegroups.com
This documentation seems to be out of date.
SoapObject extends AttributeContainer, which is where the addAttribute function comes from.
--
Andrew Oppenlander

João Cruz

unread,
Sep 12, 2011, 10:06:16 AM9/12/11
to ksoap2-android
I downloaded the latest version of the KSOAP2, and my class SoapObject
doesn't have the "addProperty" method. Even the class
AttributeContainer is not available.

I tried 2 libraries from http://sourceforge.net/projects/ksoap2/:
ksoap2-j2me-core-2.-2.1.2.jar
ksoap2-j2se-full-2.1.2.jar

and same thing on both. Is there a version with that implementation of
SoapObject that extends attributeContainer?

On Sep 12, 2:09 pm, Andrew Oppenlander <andrew.oppenlan...@gmail.com>
wrote:
> This documentation seems to be out of date.
> SoapObject<https://github.com/mosabua/ksoap2-android/blob/master/ksoap2-base/src...>extendsAttributeContainer<https://github.com/mosabua/ksoap2-android/blob/master/ksoap2-base/src...>,
> which is where the addAttribute function comes from.
>
>
>
>
>
>
>
>
>
> On Mon, Sep 12, 2011 at 6:21 AM, João Cruz <jtcru...@gmail.com> wrote:
>
> >http://ksoap2.sourceforge.net/doc/api/org/ksoap2/serialization/SoapOb...

Andrew Oppenlander

unread,
Sep 12, 2011, 10:16:03 AM9/12/11
to ksoap2-...@googlegroups.com
This is not the latest version.
The project homepage is located at http://code.google.com/p/ksoap2-android/
--
Andrew Oppenlander

João Cruz

unread,
Sep 12, 2011, 10:25:19 AM9/12/11
to ksoap2-android
Okey, found the problem. I actually had an older version of KSOAP2.
I've downloaded the newer one and it's now working.
Thank you for your patience.

PS: just an advice, if you or the developers own this site
http://ksoap2.sourceforge.net/
please put a note there that it is outdated and there is a new version
of the lib.

Best regards,
João Cruz

On Sep 12, 3:06 pm, João Cruz <jtcru...@gmail.com> wrote:
> I downloaded the latest version of the KSOAP2, and my class SoapObject
> doesn't have the "addProperty" method. Even the class
> AttributeContainer is not available.
>
> I tried 2 libraries fromhttp://sourceforge.net/projects/ksoap2/:

Manfred Moser

unread,
Sep 13, 2011, 1:55:46 AM9/13/11
to ksoap2-...@googlegroups.com
We dont have any control over the ksoap2 project on sourceforge and it is pretty quiet there.. thats why this project and mailing list exists. I added a remark about this to the top pinned post on the list here.

Similar stuff is already on the web site.
Reply all
Reply to author
Forward
0 new messages