Hi This is my first time to work on soap so I have some problem here I am unable to parse
soap object.I am using (ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar) this
librery for soap.so here I want to make separate Bean class for these five fields and
store it into Arraylist or hashmap.Please give me some suggestion for this soap object
parsing.
catalogCategoryTree{category_id=1; parent_id=0; name=Root; position=1; level=0;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=3;
parent_id=1; name=Root Catalog; is_active=1; position=3; level=1;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=10;
parent_id=3; name=Furniture; is_active=1; position=10; level=2;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=23;
parent_id=10; name=Bedroom; is_active=1; position=1; level=3;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=22;
parent_id=10; name=Living Room; is_active=1; position=23; level=3;
children=ArrayOfCatalogCategoryEntities{}; }; }; };
item=catalogCategoryEntity{category_id=13; parent_id=3; name=Electronics; is_active=1;
position=13; level=2;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=8;
parent_id=13; name=Cell Phones; is_active=1; position=8; level=3;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=15;
parent_id=13; name=Computers; is_active=1; position=9; level=3;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=27;
parent_id=15; name=Build Your Own; is_active=1; position=1; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=28;
parent_id=15; name=Laptops; is_active=1; position=2; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=29;
parent_id=13; name=Hard Drives; is_active=1; position=3; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=30;
parent_id=13; name=Monitors; is_active=1; position=4; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=31;
parent_id=13; name=RAM / Memory; is_active=1; position=5; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=32;
parent_id=13; name=Cases; is_active=1; position=6; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=33;
parent_id=13; name=Processors; is_active=1; position=7; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=34;
parent_id=13; name=Peripherals; is_active=1; position=8; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; }; };
item=catalogCategoryEntity{category_id=12; parent_id=13; name=Cameras; is_active=1;
position=13; level=3;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=25;
parent_id=12; name=Accessories; is_active=1; position=25; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=26;
parent_id=12; name=Digital Cameras; is_active=1; position=26; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; }; }; }; };
item=catalogCategoryEntity{category_id=18; parent_id=3; name=Apparel; is_active=1;
position=14; level=2;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=4;
parent_id=18; name=Shirts; is_active=1; position=4; level=3;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=5;
parent_id=18; name=Shoes; is_active=1; position=5; level=3;
children=ArrayOfCatalogCategoryEntities{item=catalogCategoryEntity{category_id=16;
parent_id=5; name=Mens; is_active=1; position=16; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; item=catalogCategoryEntity{category_id=17;
parent_id=5; name=Womens; is_active=1; position=17; level=4;
children=ArrayOfCatalogCategoryEntities{}; }; }; };
item=catalogCategoryEntity{category_id=19; parent_id=18; name=Hoodies; is_active=1;
position=19; level=3; children=ArrayOfCatalogCategoryEntities{}; };
item=catalogCategoryEntity{category_id=24; parent_id=18; name=Pants; is_active=0;
position=24; level=3; children=ArrayOfCatalogCategoryEntities{}; }; }; };
item=catalogCategoryEntity{category_id=20; parent_id=3; name=Household Items; is_active=0;
position=20; level=2
Try below code, androidHttpTransport is HttpTransportSE object. Then you will get the normal xml response and parse it using any parser like sax, or pull parser.
My full code is given below, try this out with necessary changes..
YOU CAN DO IT FOR EACH OBJECT[in your case 3].
Ksoap provides one more useful method called getPropertyCount() which tells you the no of object in the response.
kSOAP GIVES THE FOLLOWING EXAMPLE LINKS HIGHLY USEFUL I SUGGEST YOU GO THROUGH IT.
https://code.google.com/p/ksoap2-android/wiki/Links