Caching Web Service Calls when disconnected. (C# Project)

G

Guest

Hello,

First time poster here. We are developing an application running on the
Pocket PC O/s that connects to a Java application server. We have real
time services working. We are now developing code for a disconnected
state.

On the pocket PC we catch a SoapException, letting us know the system is
unavailable. At this point, I would like to start caching pertinent web
service
calls. My first question is how should these web service calls be stored. As
raw XML? How to save these message so I may call the web service again
asynchronously? During the asynch call, I still need to make sure it
completed.

I am thinking I would start a thread that would wake up and attempt to
reprocess
the first of these cached messages. If unsuccessful, it would go back to
sleep. If successful, it would run thru any saved messages and set back to a
connected or real time mode.

Here is a sample service ....
// DimFreight Service ----------------------------------------------------
public void DimFreight(string mode, string freightlKey, string length,
string width, string height, out string exceptionCode)
{
string nowDate = DateTime.Now.ToString("yyyymmdd");
string nowTime = DateTime.Now.ToString("HHMMss");
exceptionCode = "";
Global global = Global.GetGlobals();

// Call Service
freightService.FreightService service = new freightService.FreightService();
service.Url = FREIGHT_INTERFACE_URL;
try
{
service.DimFreight(mode, global.GetDevice().DeviceID,
global.getEmployee().ID, freightKey, length, width, height, nowDate, nowTime);
}
catch(SoapException soapEx)
{
exceptionCode = soapEx.GetBaseException().Message;
}
catch(Exception ex)
{
exceptionCode = ex.Message;
}
} //End - DimFreight ----------------------------------------------------
 
G

Guest

I implemented a similar solution using the MapPoint web service. Basically
I logged all failed calls to a text file (for persistence) and had a thread
that periodically checked for service availability, when service existed, it
would get data from the MapPoint server (geocode collected GPS data) and
then send it on to my web service. Once that was successful, it removed the
item from the file. The primary consideration is whether you want FIFO
(queue) or LIFO (stack) handling of the messages, but neither is difficult.

-Chris
 
S

Sergey Bogdanov

I had the same problem in one of my projects and I had solved it with
Microsoft Offline Application Block. Since at that time there was no
CF.NET version of Offline Block I had to port some parts of it by myself.

At this moment OpenNETCF has the Microsoft Application Block for CF.NET
which is available for download here:
http://www.opennetcf.org/PermaLink.aspx?guid=b876e34a-deef-45ce-ace9-f1b35813db79

To read more about Offline block see this link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/offline-ap01.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top