RE: ksoap + RIM + in a separate thread

"Steve Porter" <[email protected]> Mon, 22 Mar 2004 15:49:47 -0500
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C4104F.365A67EC
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Nathan:
=20
Thanks for the email (ps. this is the email accounts that's registered =
on the list).  That is something I was thinking of doing.  It just seems =
like such a pain at this stage to do that. (I have written a ton of code =
already, and will now have to retrofit it).
=20
What do people think of adding this functionality to KSOAP itself?  It =
would seem the HTTP transport class is sort of begging for this, and =
seeing as KSOAP is (at least in my, very possibly wrong, understanding) =
targetted at J2ME devices.
=20
I mean it would be great to remove this headache and mental roadblock =
for other developers, and I certainly think it's doable.
=20
Regards,
Steve

-----Original Message-----
From: Nathanial Freitas [mailto:[email protected]]
Sent: Monday, March 22, 2004 3:16 PM
To: [email protected]
Subject: RE: Ksoap: ksoap + RIM + in a separate thread


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


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_01C4104F.365A67EC
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2>Nathan:</FONT></SPAN></DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =
size=3D2>Thanks=20
for the email (ps. this is the email accounts that's registered on the=20
list).&nbsp; That is something I was thinking of doing.&nbsp; It just =
seems like=20
such a pain at this stage to do that. (I have written a ton of code =
already, and=20
will now have to retrofit it).</FONT></SPAN></DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =
size=3D2>What=20
do people think of adding this functionality to KSOAP itself?&nbsp; It =
would=20
seem the HTTP transport class is sort of begging for this, and seeing as =
KSOAP=20
is (at least in my, very possibly wrong, understanding) targetted at =
J2ME=20
devices.</FONT></SPAN></DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =
size=3D2>I mean=20
it would be great to remove this headache and mental roadblock for other =

developers, and I certainly think it's doable.</FONT></SPAN></DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D398164720-22032004><FONT face=3DArial color=3D#0000ff =

size=3D2>Steve</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Nathanial Freitas=20
  [mailto:[email protected]]<BR><B>Sent:</B> Monday, March =
22, 2004=20
  3:16 PM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> RE: Ksoap: =
ksoap +=20
  RIM + in a separate thread<BR><BR></FONT></DIV>
  <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=20
  send/receive web-style model. Think of how the rest of a Blackberry =
works and=20
  then model that. This is a good approach for J2ME on *any* device, =
because if=20
  you put HTTP in the main thread, you'll block all UI=20
  interaction.</FONT></SPAN></DIV><SPAN 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=20
  a 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=20
  queue in a serial manner. When it has its response (or error), then =
pass it=20
  back to 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=20
  a pretty common design, and one that I've had a lot of success with. =
You just=20
  have to break the sync/web mentality of both you and your users. The =
good news=20
  is 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=20
  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,=20
    2004 4:26 AM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> =
Ksoap: ksoap=20
    + RIM + 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=20
    way as to put the data fetcher on a separate thread.&nbsp; I access =
a *lot*=20
    of web services from my application (currently over 25 comprise the=20
    application, and no it's not poor design, it's a HUGE scope=20
    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=20
size=3D2>Steve</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C4104F.365A67EC--