RE: ksoap + RIM + in a separate thread

"Nathanial Freitas" <[email protected]> Mon, 22 Mar 2004 12:16:04 -0800
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <0CD59F58C0C95D42B5FFD2D6659B2F5CAEA9E6@usmilm004.palm1.palmone.com>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C4104A.80B59B4A
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

You essentially need to design your application so that its not a sync
send/receive web-style model. Think of how the rest of a Blackberry
works and then model that. This is a good approach for J2ME on *any*
device, because if you put HTTP in the main thread, you'll block all UI
interaction.

A quick recommendation is to create a class to store SOAP messages and
their responses, and a reference to a callback interface to return the
response object to once its processed. Then create instances of that
object and place them into a FIFO queue (Vector, Hashtable, Stack, etc).
Write a handler running in a seperate thread, which sleeps until you
notify it to wakeup and process whatever it finds in the queue in a
serial manner. When it has its response (or error), then pass it back to
the callback interface (which would then present some UI to the user).
=20
It's a pretty common design, and one that I've had a lot of success
with. You just have to break the sync/web mentality of both you and your
users. The good news is that this is a cheap way to handle on/offline
modes, as well.
=20
Regards,
   Nathan

	-----Original Message-----
	From: Steve Porter [mailto:[email protected]]=20
	Sent: Monday, March 22, 2004 4:26 AM
	To: [email protected]
	Subject: Ksoap: ksoap + RIM + in a separate thread
=09
=09
	Ok.. got KSOAP2 talking to .net webservices.. I figured that
would be the hard part, but not too bad.=20
	=20
	My problem is this.  On the RIM Blackberry units, I've been told
all HTTP fetch requests must be on a separate thread.  Anyone here have
any ideas how to partition KSOAP in such a way as to put the data
fetcher on a separate thread.  I access a *lot* of web services from my
application (currently over 25 comprise the application, and no it's not
poor design, it's a HUGE scope application).
	=20
	Any help (or even better code) would be appreciated.
	=20
	Steve


------_=_NextPart_001_01C4104A.80B59B4A
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D250430820-22032004><FONT face=3DArial color=3D#0000ff =
size=3D2>You=20
essentially need to design your application so that its not a sync =
send/receive=20
web-style model. Think of how the rest of a Blackberry works and then =
model=20
that. This is a good approach for J2ME on *any* device, because if you =
put HTTP=20
in the main thread, you'll block all UI =
interaction.</FONT></SPAN></DIV><SPAN=20
class=3D250430820-22032004>
<DIV><BR><FONT face=3DArial color=3D#0000ff size=3D2>A quick =
recommendation is to=20
create a class to store SOAP messages and their responses, and a =
reference to a=20
callback interface to return the response object to once its processed. =
Then=20
create instances of that object and place them into a FIFO queue =
(Vector,=20
Hashtable, Stack, etc). Write a handler running in a seperate thread, =
which=20
sleeps until you notify it to wakeup and process whatever it finds in =
the queue=20
in a serial manner. When it has its response (or error), then pass it =
back to=20
the callback interface (which would then present some UI to the=20
user).</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D250430820-22032004><FONT face=3DArial color=3D#0000ff =
size=3D2>It's a=20
pretty common design, and one that I've had a lot of success with. You =
just have=20
to break the sync/web mentality of both you and your users. The good =
news is=20
that this is a cheap way to handle on/offline modes, as=20
well.</FONT></SPAN></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV></SPAN><SPAN class=3D250430820-22032004><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D250430820-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2>&nbsp;&nbsp; Nathan</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr =
align=3Dleft><FONT=20
  face=3DTahoma size=3D2>-----Original Message-----<BR><B>From:</B> =
Steve Porter=20
  [mailto:[email protected]] <BR><B>Sent:</B> Monday, March =
22, 2004=20
  4:26 AM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> Ksoap: =
ksoap + RIM=20
  + in a separate thread<BR><BR></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Ok.. got KSOAP2 talking to .net =
webservices.. I=20
  figured that would be the hard part, but not too bad. </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>My problem is this.&nbsp; On the RIM =
Blackberry=20
  units, I've been told all HTTP fetch requests must be on a separate=20
  thread.&nbsp; Anyone here have any ideas how to partition KSOAP in =
such a way=20
  as to put the data fetcher on a separate thread.&nbsp; I access a =
*lot* of web=20
  services from my application (currently over 25 comprise the =
application, and=20
  no it's not poor design, it's a HUGE scope application).</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Any help (or even better code) would =
be=20
  appreciated.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2>Steve</FONT></DIV></BLOCKQUOTE></BODY></HTML>
=00
------_=_NextPart_001_01C4104A.80B59B4A--