Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor
Accepted Solution

Deserialize XML to object

Searched around the web but did not find any real good answers for Blackberry.


Anyone having some useful tip? Tought of coding something but then it would be with hard coded variable names since I do not know of a way to reference a variable name "dynamically" in code.

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Deserialize XML to object

we use ksoap2 to serialize/deserialize objects to/from xml.
depends on the project complexity if it is worth the overhead or easier to write some serializing-code yourself.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Deserialize XML to object

Thanks Simon. I will have a look

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Deserialize XML to object

Simon

 

I found the Sourceforge project ksoap2. It just had jar file that was downloadable, Have spent an hour chasing documentation on how to use the product. I only got a tip of looking at the ksoap2-android project for documentation but that was not very helpful.

 

Tou know where to find it?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Deserialize XML to object

the sourceforge project also has the source available, for example to view here:
http://ksoap2.svn.sourceforge.net/viewvc/ksoap2/

you can find plenty of posts about ksoap2 here, but usually it is used for webservice access.
some guides:
http://www.codeproject.com/Articles/29305/Consuming-NET-Web-Services-via-the-kSOAP-library

http://blog.bayestech.com/?p=78

the most important part for you is the interface kserializable
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Deserialize XML to object

Back to this problem after solving the problem of actually getting the XML files that arrived as a zip file from a server

and store them in persistant storage

 

I have tried to read the documentaion on ksoap, actually its ksoap2 and I am totally overwelmed. It feels like I have to learn all the details on how all the machinery in a car interacts and how the single components work in detail.

 

Well I know all that. Took some time to learn.  As a hobby I do work on 60-80 American cars and improve them.

 

Now all I want is to deserialize that XML file I get.  Any help is appreciated. Like, just driving the car  :-)

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Deserialize XML to object

kSoap is a little different to just processing XML.  If all you want to do is process XML, then this might help, and uses a builtin parser so you don't have to add any library to your application:

http://supportforums.blackberry.com/t5/Java-Development/Use-the-XML-Parser/ta-p/445210

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Deserialize XML to object

Found this:

http://jibx.sourceforge.net/eclipse/index.html

 

Works for J2ME

Installs to Eclipse via Software Install

lots of examples

Will try it out

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Deserialize XML to object

JibX

 

No. Strange problems with workspace.  Back to square one.  Ksoap2.  Actually KSoap2-android after a recommendation from the mailing list 

Just one jar file to install. Put it in plugins and defined in build path, Just that.

 

Error while packaging test project with no soap2 code.

 

org/kxml2/wap/wv/WV.class: Error!: Invalid class file: Incorrect classfile version
Packaging project TestDriver failed (took 0.906 seconds).

 

put it on the mailing list. we will se. Never ending story

 

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Deserialize XML to object

I do not understand why you are using kSoap if you just have an XML stream/file to process.  kSoap is only for SOAP type communications with Web Servers and most Servers will offer other packaging methods which are easier to process. 

Please use plain text.