Click here to Skip to main content
13,355,726 members (63,138 online)
Click here to Skip to main content
Add your own
alternative version


39 bookmarked
Posted 27 Nov 2006

Developing a wireless workflow automation client on Pocket PC/PDAs with a Web Service

, 3 Mar 2009
Rate this:
Please Sign up or sign in to vote.
This article focuses on developing a workflow client device application for Pocket PC in C# 2003.


Workflow automation clients are often web based, an easy approach to implement business process flows and deploy workflow clients over a large scale in an organization. These workflow clients and processes are mostly developed with components (DLLs, SDKs) that come with BPM software. These DLLs (or .NET assemblies) embed most of the workflow functionalities and routing mechanism. However, such workflow automation clients have not been designed for devices like Pocket PC/Palm and SmartPhones.

To access such heavy sites on SmartPhones/Pocket PC is not ideal, and firewall security can also prevent the user from accessing a site. For Pocket PC, we will develop a device based application which will query from a Web Service and then the Web Service will, in turn, implements all kinds of business rules and also implements .NET assemblies or DLL methods and properties. This Web Service(s) give back results to the device application using XML interfaces/SOAP over HTTP protocol. That is, the Pocket PC application gets data and displays it to the user. Similarly, the user can submit a task which will update the database status, and another user sitting in an organization/company working on an ordinary desktop PC will view it on a web based workflow client.

We will first develop a Web Service which has the logic for the connection to the database and does the querying from the database.

Note: I've used sample databases. Remember, the database that contains the tracking ID of a workflow should be a workflow database that comes with a workflow BPM software. It is also a good practice to wrap up all data access code using workflow databases in APIs. If APIs come with workflow software as SDK, it's better to use them.

Step 1

Go to VS 2003->New Project->Visual C# Projects. Select the ASP.NET Web Service template. In the Location field, specify the project name.

Sample screenshot

Add two new classes to the project. Name them DatabaseCS.cs and DataAccess.cs.

DatabaseCS.cs will define the function below:

public short OpenConnection(string strServername, string struser, 
                            string strpwd , string strDatabase)

It receives parameters for the database name, server name etc., from the Web Method.

DataAccess.cs will have the overloaded Execute_Dataset function:

public short Execute_Dataset(DatabaseCS DBcs,string StrQueryl)
//overloaded function

It receives the active open connection object in the DatabaseCS class, query string from the Web Method (ASMX file), and queries the database and populates a DataSet.

Step 2

Web Method

To use these functions in the Web Method, we write code in the .asmx file as:

public DataSet Select(string strQuery,ArrayList DBParm)
    strServername= DBParm[0].ToString();
    struser= DBParm[1].ToString();
    strpwd= DBParm[2].ToString();
    strDatabase= DBParm[3].ToString();
    DataSet dsselect=new DataSet();

    DatabaseCS DBcs=new DatabaseCS();
    short iretval=0;
    iretval=DBcs.OpenConnection( strServername, 
                struser, strpwd , strDatabase);

    if(iretval> 0)
        DataAccess DBAccess=new DataAccess(strQuery);
        short ierror= DBAccess.Execute_Dataset(DBcs,strQuery);

    return dsselect;


DBParam is an ArrayList which contains the database name, server name, user ID, and the password.

Step 3

Build the project. Access the Web Service on Internet Explorer.

Yes, we can see our Web Method.

Step 4

The next step is to develop a client application for Pocket PC which will access these Web Service methods.

Start New Project->Visual C# Project->Smart Device Application. Enter Wirelessworkflowclient in the Name field. Select Drive/Folder in the Location field.

Sample screenshot

Step 5

In the Smart Device application Wizard, select Pocket PC from the list marked "What platform do you want to target" and select Windows Application from the list marked "What project type do you want to create".

Sample screenshot

Click/press OK.

Add a MainMenu, InputPanel, and a ContextMenu on the main form. Now drag a DataGrid control on the main form.

Step 6

Now we will add our web reference to this project. Go to Solution Explorer, right click and select Add Web Reference.

Sample screenshot

Type the address of the Web Service in the URL field and click "Go".

Note: Do not write "Localhost" for the URL in this step. Use the IP address if you are on a LAN, or the domain name of your server. If you are testing your application on an emulator (that is sure) and your PC is on a LAN, use the IP address. If your PC is not on LAN and not connected to the Internet, use the hostname of your PC. However, before launching the application on the emulator, install the Microsoft Loopback Adapter LAN. See further configuration tips at the end of this article.

Sample screenshot

Type the name of the Web Reference in the "Web Reference name" field. Click "Add Reference".

Step 7

Now write code to access data from the database and display it in the DataGrid. We are concerned about two databases here. So one fetch from the Orders/Products database (e.g., assume Northwind), and the other is, of course, your major workflow database. Define the variables for the two databases and an ArrayList which accommodates these variables to pass them to the Web Service. Initialize the ArrayList in MainScreen() (the constructor of your form). Create an instance of the Web Service.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace Wirelessworkflowclient

/// <summary>
/// Summary description for Form1.
/// </summary>

public class MainScreen : System.Windows.Forms.Form
    //WebReference11.MobMService serv = 
       new WebReference11.MobMService();
    WbService.Wireless serv = 
       new Wirelessworkflowclient.WbService.Wireless();
    string currentlogeduser;

    ArrayList DBParam=new ArrayList(4);
    ArrayList DBParam2=new ArrayList(4);
    string strServername="myserverSQL";
    string struser="sa";
    string strpwd ="";
    string strDatabase="ProcessesDB";
    string strServernameM="myserverSQL"; 
    string struserM="sa";
    string strpwdM ="";
    string strDatabaseM="NORTHWind";

    private System.Windows.Forms.ContextMenu contextMenu1;
    private System.Windows.Forms.Label Name;
    private System.Windows.Forms.Label ID;
    private System.Windows.Forms.DataGrid DGTasks;
    private Microsoft.WindowsCE.Forms.InputPanel inputPanelT;
    private System.Windows.Forms.MainMenu mnuM;
    private System.Windows.Forms.Label HD;

    public MainScreen()
        // Required for Windows Form Designer support

        //initrilize arraylist with database parms
        DBParam.Add(struser );
        DBParam2.Add(struserM );
        DBParam2.Add(strpwdM );
        DBParam2.Add(strDatabaseM );

        // TODO: Add any constructor code after InitializeComponent call

    public void FetchRemoteData(string login)
        Cursor.Current =Cursors.WaitCursor;
        string Msg="";
        ID.Text ="User ID:"+login;
        //try this to check if your web service 
        //url in reference.cs is updated to right url.

            DataSet dsnew =new DataSet();
            DataSet dsname=new DataSet();
            dsname=serv.Select("select * from Tables1 where name='" + 
                               login.Trim() + "'",DBParam.ToArray());
            Name.Text =dsname.Tables[0].Rows[0]["Fullname"].ToString();
            string strq="select Northwind..Products.Productname" + 
                        " Product , ProcessesDB..Process.Agenda ," + 
                        "from ProcessesDB ,Northwind..Products " + 
                        "where  ProcessesDB..Process." + 
                        "ActiveLoginClient ='" + login +
                        "' and Northwind..Products.ProductID=incno " + 
                        "order by Northwind..[Products].ProductID desc";
            dsnew = serv.Select(strq ,DBParam2.ToArray());
                    DGTasks.DataSource =dsnew.Tables[0];
                    Msg ="No New data in your workflow client";
                Msg ="Server Unavaialable!";
        catch(Exception ex2)
            MessageBox.Show (ex2.Message);
            Msg =ex2.Message;
    catch(Exception exx)
        MessageBox.Show ("2" + exx.Message);
        Msg =exx.Message;
    Cursor.Current =Cursors.Default;

In the Form Load event, write this code:


Note: You can use another form for login and access authority. Write a method in the Web Service which accepts the username, password, and verifies them from database to send a true/false value to the client.

Step 8

If your code finished here, it is time to build the project and deploy it on the emulator.

Select Build->Build Solution from the menu.

Sample screenshot

In the next step, select "Pocket PC 2002 emulator" from the list and click Deploy.

Sample screenshot

Here we go...

Sample screenshot

Sample screenshot

Configuration of the Loopback Adapter: Control Panel->Add Hardware->Add Microsoft Loopback Adapter.

After installation, in the properties of the Microsoft Loopback Adapter, select TCP/IP, and enter the IP address and the subnet mask Similary, on the emulator, select Network Adapters->N2000 Ethernet Driver.

Sample screenshot

Click Properties. Enter IP address and subnet mask

Sample screenshot

If there is problem in the connection with the Web Service from the emulator, change the device ID of the emulator in the Settings for the emulator.


We designed and developed a Web Service which is generic and used for the purpose of database connections and manipulations. However, BPM software provide additional features and provide DLLs for user access and other manipulation. You can also embed that functionality into a Web Service.

The purpose of the Pocket PC device is to get all workflow task data for authorized users.

Happy programming!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United Kingdom United Kingdom

You may also be interested in...


Comments and Discussions

GeneralGot WebException during function call Pin
PrasertHong28-Mar-07 1:24
memberPrasertHong28-Mar-07 1:24 
AnswerRe: Got WebException during function call Pin
Zenab_Zenab1-May-07 6:43
memberZenab_Zenab1-May-07 6:43 
GeneralRe: Got WebException during function call Pin
PrasertHong1-May-07 18:01
memberPrasertHong1-May-07 18:01 
GeneralRe: Got WebException during function call Pin
Member 769351529-Mar-11 19:52
memberMember 769351529-Mar-11 19:52 
GeneralRe: Got WebException during function call Pin
imtiazahmad28-Jun-11 5:27
memberimtiazahmad28-Jun-11 5:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 3 Mar 2009
Article Copyright 2006 by Zenab_Zenab
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid