Getting Objects from Web Service

66 views
Skip to first unread message

Junel Mata

unread,
Nov 7, 2014, 1:44:31 AM11/7/14
to codenameone...@googlegroups.com
How can I read my object or list of objects from my web service to my device?And how to implement it in the client and server side?

Shai Almog

unread,
Nov 7, 2014, 10:57:51 AM11/7/14
to codenameone...@googlegroups.com
Did you look at the webservice wizard?
http://www.codenameone.com/how-do-i---access-remote-webservices-perform-operations-on-the-server.html

It allows you to externalize an object but generally you are better off just passing method calls with simpler types.

Junel Mata

unread,
Nov 9, 2014, 7:10:37 PM11/9/14
to codenameone...@googlegroups.com
Yes, I watched the webservice wizard tutorial and you just introduced the externalize type but did not gave some examples on how to use it. how can I apply it on the server and client side? I also read the tutorial of steve about externalization but he didn't  stated where side of the application to apply it or it should be applied to both client and server. Can I possibly create a method that can return a 2D array? because I am making a data driven application and I consider each row of the table as an object. 

Shai Almog

unread,
Nov 9, 2014, 11:47:50 PM11/9/14
to codenameone...@googlegroups.com
You will need the object to exist identically both in the client and the server since we can't serialize the bytecode (e.g. on iOS its really native C code).
2d arrays in Java are a bit in efficient for storing/transmitting symmetric data like a table because this can be true: arr[1].length != arr[2].length
So we will need to transmit all lengths and access is slower (double array lookup). You are better off using a single dimension array with a multiplier for data.

Junel Mata

unread,
Nov 10, 2014, 1:21:54 AM11/10/14
to codenameone...@googlegroups.com
Can I possibly pass a list of string array from the server to the client application?Can you give me some example of a multiplier for data?

Shai Almog

unread,
Nov 10, 2014, 11:02:42 AM11/10/14
to codenameone...@googlegroups.com
To "fake" multi array just use arr[arr1Off + arr2Off * size] which is similar to (but faster than) arr[arr1Off][arr2Off].

There is a String[] option just above externalizable.

Junel Mata

unread,
Nov 11, 2014, 2:02:21 AM11/11/14
to codenameone...@googlegroups.com
I followed your suggestion and after applying it, I came up with this exception:
java.io.IOException: Server error: 500
at com.codename1.io.WebServiceProxyCall.invokeWebserviceSync(WebServiceProxyCall.java:192)
at com.icomm.ibcmobile.WebServiceProxy.getCustomerInfo(WebServiceProxy.java:26)
at com.icomm.ibcmobile.CustomerAccount$11.actionPerformed(CustomerAccount.java:284)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:345)
at com.codename1.ui.Button.fireActionEvent(Button.java:393)
at com.codename1.ui.Button.released(Button.java:424)
at com.codename1.ui.Button.pointerReleased(Button.java:512)
at com.codename1.ui.Form.pointerReleased(Form.java:2365)
at com.codename1.ui.Form.pointerReleased(Form.java:2301)
at com.codename1.ui.Component.pointerReleased(Component.java:2596)
at com.codename1.ui.Display.handleEvent(Display.java:1903)
at com.codename1.ui.Display.edtLoopImpl(Display.java:999)
at com.codename1.ui.Display.mainEDTLoop(Display.java:930)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Can you adviseme about this?

Shai Almog

unread,
Nov 11, 2014, 10:02:15 AM11/11/14
to codenameone...@googlegroups.com
This is a server error. You need to provide the stack from the server where the actual error happened.

Junel Mata

unread,
Nov 11, 2014, 6:51:41 PM11/11/14
to codenameone...@googlegroups.com
Yes, I just figured out my error yesterday and I already solved it. Thanks
Reply all
Reply to author
Forward
0 new messages