Web Service On Windows Mobile

Yes.

I’ve seen many people, who are facing issues while accessing Web Service on Windows Mobile enabled devices. Although there are lot of posts on blogs and forums, sometimes, it doesn’t work. Why? Because there are lot of issues.

Let’s see all those issues and solve them. I hope that readers of this blog are aware of creating Web Services in C# / VB.NET using Visual Studio 2005 or 2008.

If not, lets create a simple Hello World web service i.e. a web method, when called will return a Hello World string. By default, when you create any web service in Visual Studio it gives you “Hello World” method as a web method which can be consumed (or used) as web service.

Now, lets see how we can access this web service in Windows Mobile based applications.

1. Create a Windows Mobile based Windows Forms Application

2. Add a Web Reference to your web-service. Now, here is the glitch. While adding a reference it uses your system as a localhost (in some cases port no attached) but when you deploy your application on Windows Mobile, actually your web-service is still running on your development machine and not on your device. Hence, change this localhost with your development machine name OR machine name on which your web service is hosted. Don’t use IP address. Why? Because, when you attach your mobile device to the machine, using DHCP it gets automatic IP address. So, don’t set any IP address rather use machine name.

3. Now, create a proxy class and use that web service in your application.

4. To test the application, run it in emulator or on device. Now, if you’re running your application on real physical device then it should work properly. But, if you’re running it on emulator, then make sure that…

a. In ActiveSync -> File -> Connection Settings, you have allowed DMA connections.

b. When Device Emulator is running, in Device Emulator Manager, Cradle your device. That means, it’ll connect your device emulator to your machine.

This ways you should be able to consume web service hosted on your machine onto your mobile device (whether real-physical device OR emulator).

I hope, this clarifies and solves most of the issues.

Soon, I will create a Screen Cast and host it on my blog.

Namaste…..

Mayur Tendulkar | Microsoft India

Advertisements

Published by

Mayur Tendulkar

Working as a Program Manager for Xamarin in Microsoft. More details at: https://about.me/tendulkar

10 thoughts on “Web Service On Windows Mobile”

  1. Hi Mayur. When I invoke the service, instead of getting simply Hello World, I get the following XML code. How do remove that?“xml version=”1.0″ encoding=”utf-8” ? string xmlns = “http://impetus.co.in/””Hello World/stringThanks in advance

    Like

  2. Kumar Kush :>1. Thanks for appreaciating.2. You’re invoking that web-service. I’ll say you need to use it, in some applications OR CONSUME it. Will create one screen-cast on it.Dhaval :>My pleasure sir. Just coincidence and I hit the right topic. Let me know if I can put more over here.

    Like

  3. Yes I have a featre request in your demo. please make ur demo webservice to transfer images or audio too. and consume them with or witout using datagrid. i am currently using an arraylist to transfer but unable to marshal the Arraylist at the consumer[client]. EEELLLPPP!!!

    Like

  4. Hi,I am trying to run a webservice on windows mobile 5.0 device via visual studio. i am not able to change the localhost name to my development pc name. can u please tell me how to do this.I am new to webservice and asp, so please help.

    Like

  5. Hi Mayur, Your blog provided me what i was exactly looking for, but i have a doubt. I an new to C# and .Net, can you please tell me how to do the step 3 that is creating a proxy class, is it created automatically? If yes then how to use it in the project.Thanks Aryan

    Like

  6. Hi Mayur,

    Your illustration was really helpful. I am using windows mobile 5.0 on vista (VS 2008). I have set the connection in windows mobile device center to DMA. Still I get the error “connection is not set”.

    Can u please help me with this?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s