Click here to Skip to main content
Click here to Skip to main content
Go to top

Consuming .NET Web Services on Pocket PC - Part 1

, 7 Jun 2004
Rate this:
Please Sign up or sign in to vote.
An article on Consuming web Service on PocketPC

Introduction

If you haven't heard about Web Services or PDAs by now, then it's high time you got out and this is just the article to help you step into the daylight. In this article we'll demonstrate how to design a client application for the PocketPC platform in Visual Studio .NET 2003 and use it to connect to a Web Service.

Web Services

Before we begin our little demonstration, we should briefly review some general concepts. Web Services are one of the most interesting technologies to emerge recently. To keep it simple, we can think of Web Services as modules of code that we can access over the Internet. They are very similar to class libraries, only they physically reside on a remote server rather than in our own application code. We can design client applications that communicate with Web Services, sending them parameters to receive generated results in true black-box fashion. The protocol used in this kind of communication is Simple Object Access Protocol (SOAP), an XML-based mark-up language. When Web Services first came on the scene, developers had to be able to understand, and be able to write, SOAP messages. With Visual Studio .NET (VS.NET 2003), though, most of that is hidden from us and we can concentrate more on application design.

Because SOAP is a form of XML, any platform or application can theoretically read it - of course, a proper parser is needed to be able to do so. We can write a Web Service in Java, for example, and host it on some Linux server on the other side of the globe and then access it, via the Internet, from a Visual Basic application running on a Windows desktop machine. In this way, organizations can expose certain data stores or applications to the public if they so choose - and they don't have to be concerned with providing the data in varying formats in order to appease varying platforms.

Setting Up a Client Application

For the rest of this article we'll be using VS.NET 2003 to target the PocketPC platform. We'll be connecting to a language translation Web Service to give the PDA user a way to translate words and phrases to and from several different languages. Although the concepts presented herein are fairly general, there are some specifics that may not jibe with other versions of VS.NET or other IDEs. In addition, we'll be using the PDA emulator that is installed with VS.NET in order to do our debugging. If you wish, you may debug and test by deploying the application directly to a PDA, but that method is a bit more time-consuming than using the emulator. We usually find it more efficient to test thoroughly using the emulator and then deploy the application to a PDA once it has received our first stamp of approval. Without any further ado, then, let's fire up VS.NET2003. First of all, select File|New|Project from the main menu and then in the "New Project" dialog select the "Smart Device Application" item for the .NET language of your choice (in this article we'll be using C#). Don't forget to give the project a name. We named it "HoytsCinema".

Once we've chosen to create our new project, another dialog appears, asking us to specify what PDA platform to target and what type of PDA project we wish to create. We want to target the PocketPC platform (as opposed to the Windows CE platform) and to create a Windows Application (as opposed to a class library, etc.), so make the selections as shown below:

Using the code

Just follow the above pictures and you will learn how to consume a web service

    private void btnLogin_Click(object sender, System.EventArgs e)
    {  int intValid;
      //MessageBox.Show("Gopal here"); 
            
      if(txtLogin.Text ==string.Empty)
        {
        MessageBox.Show("Enter Student ID ");
        }
      else
        if(txtPassword.Text ==string.Empty)
        {
        MessageBox.Show("Enter Password");
        }
      intValid = HoytsTicket.ValidateUser(txtLogin.Text,txtPassword.Text);
      if (intValid > 0)
      {  
        this.Hide();
        Movie frmMovie = new Movie(txtLogin.Text);
        frmMovie.ShowDialog();
        frmMovie.Close();
        Application.Exit();
      }
      else
      {
        MessageBox.Show("Enter Correct Student ID and Password");
      }

    }

Points of Interest

If you have created your own web service and trying to run that on your PocketPC , you will face some problems, if you have mentioned the name as http:localhost/myWebservice.asmx. Be careful!!!!!!!! Instead of Localhost, give IP address.

History

Be in touch I am going to post very soon another article - Creating Advanced Web services using VS.NET 2003.

License

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

Share

About the Author

Gopal Panda
Web Developer
India India
No Biography provided

Comments and Discussions

 
GeneralThank you!! Pinmembergbarizon25-Jun-09 9:47 
QuestionHow to consume external web services in .net smart device application PinmemberSunitha.Tentu20-Dec-06 20:01 
GeneralProblem Consuming a Web Service PinmemberSebina10-May-06 6:17 
GeneralRe: Problem Consuming a Web Service Pinmemberninoku23-Jun-06 2:02 
GeneralVery Nice PinmemberDean Bathke12-Jun-05 6:27 
Generalproxy problem plz help Pinmembergripusa16-Mar-05 3:33 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 8 Jun 2004
Article Copyright 2004 by Gopal Panda
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid