Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  Web Development  »  Mobile Devices  »  Developing a Pocket-PC application that calls a WebService
 »  Home  »  Web Development  »  Web Services  »  Developing a Pocket-PC application that calls a WebService
Developing a Pocket-PC application that calls a WebService
by Farhan Shah | Published  04/15/2002 | Mobile Devices Web Services | Rating:
Farhan Shah

Farhan Shah is a Senior .NET Web Developer/Architect for Cardinal Solutions Inc based in Cincinnati Ohio. During his 6 year career as a developer and development lead, Farhan has designed and implemented a diverse number of mission critical software solutions using ASP.NET, VB.NET, C#, VB 6.0, Java, C++, EVT, ASP, DCOM & MTS, SQL Server, Oracle, and others.

Farhan has used Microsoft's .NET technologies since the first Beta release. Farhan has successfully launched a number of .NET applications including an order management system, and information management system for Rehab Hospital.

Most recently, Farhan has focused on Microsoft technologies including VB.NET, ASP.NET, ASP, Visual Basic 6, SQL Server, and Web Service development.


View all articles by Farhan Shah...
Developing a Pocket-PC application that calls a WebService

This article will demonstrate how to call .NET web service from Pocket PC application.  The Pocket PC application will pass data using Pocket SOAP (Simple Object Access Protocol) to the web service (therefore IIS with .NET framework is required on the server) and return result back to the Pocket PC application. 

What will you need?

  • Microsoft eMbedded Visual Tools (which is free by the way).
  • Pocket SOAP from .
  • This article assumes that you already know how to create a web service.
  • Web Server with Microsoft .NET framework installed.
  • Internet connection from Pocket PC to the web-server running the web service.

Microsoft eMbedded Visual Tools:

The Microsoft® eMbedded Visual Tools 3.0 deliver a complete desktop development environment for creating applications and system components for Windows® Powereddevices, including the Pocket PC and Handheld PC.

For more information and how to download Microsoft® eMbedded Visual Tools, please click on following link

Pocket SOAP:

This is a SOAP client COM component for the Windows family, originally targeted at PocketPC (hence the name), there is also a Win32 version that works on Windows 95/98/Me/NT4/2000/XP. The Pocket SOAP implementation is nicely packaged into a COM component running on a Pocket PC. The component is written in Microsoft eMbedded Visual C++® (eVC), and the source is available for download, too (you will find license information on the site). There is also a version for PCs (Microsoft Windows® 95/98/ME/2000 and Microsoft Windows NT® 4).

For more information and how to download Pocket SOAP, please click on following link:

Cross Platform and XML Web Services

If you are a developer and have been living on a remote Island from past two years with no internet connection and no Microsoft's sales rep around you then you missed the big news, Microsoft® finally did it, "Cross platform development" – wait, that's very strong statement, so let me rephrase "Cross platform development using .NET Web Services" and bad news is that you will need to read up on SOAP.

Web services changed the way developers design and develop applications nowadays. Now not only the functionality can be shared with-in the application but also across different platforms and over the internet. This gives new meaning to application development for wireless devices including Pocket PC.  In essence, using SOAP developers can write an application for Pocket PC that is not only very rich in functionality but also requires limited amount of memory.

How to create a Web Services:

As this article is more gear towards calling a web service from Pocket PC, I don't want to spend a lot of time on how to create a web service but on how to call a web service from eMbedded Visual Basic.  If you are new to web services then take a look at following article: Create Web Services and Web Forms Programmatically with the .NET Framework SDK.

Code walk through:

Following is a code which implements Mortgage web service. The web service has three input params (Number of months, Interest Rate and Loan Amount) and it returns monthly mortgage payment.
Option Explicit On
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://localhost/")> _

Public Class MortgageWebService

    Inherits System.Web.Services.WebService

<WebMethod(), SoapRpcMethod()> _
    Public Function MonthlyPayment_
        ByVal nMonths As ShortByVal InterestRate As Double_
        ByVal loanAmt As DecimalAs Decimal

    Dim monthlyRatetempVal As Double
    Dim unRoundedAmt As Decimal

        monthlyRate = InterestRate / 1200
        tempVal = Math.Pow(1 + monthlyRateCDbl(nMonths))
        unRoundedAmt = CDec(CDbl(loanAmt) _
                       * (monthlyRate*tempVal / (tempVal - 1)))

        Return Decimal.Round(unRoundedAmt2)

    End Function
End Class
Generated using PrettyCode.Encoder

Following is how the web service looks like in a web browser:

Just to be safe, try to call the web service from Pocket IE using emulator that comes with EVT.

Now comes the fun stuff, how will we call this web service from Pocket PC?  Pocket SOAP will do that for you and it even gets better, there is wizard available at which will write a code for you.  But we will do it old way here.

Following is how the application looks like Pocket Emulator:

Code behind the application:
Option Explicit

Private pEnvelope As PocketSOAP.CoEnvelope
Private pHTTP As PocketSOAP.HTTPTransport

Private Sub Calculate_Click()
  Dim lsRequest

  Set pEnvelope = CreateObject("pocketSOAP.Envelope.2")

  pEnvelope.MethodName = "MonthlyPayment"  ' Method Name

  pEnvelope.URI = "http://localhost/"  ' Name Space

  pEnvelope.Parameters.Create "nMonths"numMonths.Text
  pEnvelope.Parameters.Create "InterestRate"InterestRate.Text
  pEnvelope.Parameters.Create "loanAmt"loanAmt.Text

  Set pHTTP = CreateObject("PocketSOAP.HTTPTransport.2")

  ' Soap action path, you can find that in WSDL file
  pHTTP.SOAPAction = "http://localhost/MonthlyPayment"

  ' Path of actual web service
  pHTTP.Send "http://localhost/MortgageSample/Service1.asmx"_

  pEnvelope.Parse pHTTP

  Label1.Caption = "$" & pEnvelope.Parameters.Item(0).Value

End Sub
Generated using PrettyCode.Encoder

Some comments on the code:

  • You can find MethodName, URI, and SOAPAction information in WSDL file: e.g. http://localhost/MortgageSample/Service1.asmx?WSDL
  • As Web Services Description Language (WSDL) defines two styles for how an XML Web service method, which it calls an operation, can be formatted in a SOAP message: RPC and Document. RPC formatting refers to formatting the operation according to the SOAP specification for using SOAP for RPC; otherwise known as Section 7 of the SOAP specification. RPC formatting states that all parameters are encapsulated within a single XML element named after the XML Web service method and that each XML element within that XML element represents a parameter named after the parameter it is representing.
  • If your web service is returning Array then you can write a custom serializer to extract the data into a more useable form. The new WSDL tools will do all this for you, there's a alpha version available at
  • If you are using Pocket Emulator to develop, make sure you download binaries files fro PocketSOAP emulator from


This is very simple example to show how web services can be used for development of great application. Now it's up to you to create great applications e.g. Microsoft just release MapPoint .NET Basic Services 2.0 and you can take advantage of the mapping and spatial analysis functionality of this new XML Web Service. I hope you will take advantage of web services for the Pocket PC development, as it gives developers freedom to develop in any language and leveraging true power of OO development.

Also Microsoft Pocket PC 2002 SDK is been released, I haven't used it yet but I am sure it does have new .NET features. I hope you are excited about this as much as I am – and you will hit the ground running. 

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:3.625 out of 5
 16 people have rated this page
Article Score32193
Sponsored Links