• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1241
  • Last Modified:

Using Web Services from a mobile Device

Hi,

I am having problems using web services from a windows mobile device.  

I am currently using VS2008, Standard windows mobile 6.0 SDK, and I have created this on a VM (windows XP) using virtual PC 2007.

So far I have created a web service containing a web method for simple hello world (first code example) and a mobile form calling this method (2nd code example).  When I run the application it seems I cannot connect to the service with stack trace:

   at System.Net.HttpWebRequest.finishGetResponse()
   at System.Net.HttpWebRequest.GetResponse()
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at SmartDeviceProject1.Test.Service1.HelloWorld()
   at SmartDeviceProject1.Form1.menuItem1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.Menu.ProcessMnuProc(Control ctlThis, WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Form.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
   at System.Windows.Forms.Application.Run(Form fm)
   at SmartDeviceProject1.Program.Main()


As I am completely new to this area of development there is probably something straight forward left out.

Let me know if you need any further detail.


Thanks,

Fly12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
 
namespace WSExpenses
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
 
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
}
 
 
 
form1.cs
 
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
 
namespace SmartDeviceProject1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void menuItem1_Click(object sender, EventArgs e)
        {
             Test.Service1 test = new SmartDeviceProject1.Test.Service1();
             test.Url = "http://paul-virtual:1057/Service1.asmx";
             
 
 
             label1.Text = test.HelloWorld();
        }
 
 
    }
}

Open in new window

0
fly12
Asked:
fly12
  • 15
  • 15
1 Solution
 
Mikal613Commented:
were you able to add the web reference without errors?
0
 
fly12Author Commented:
Hi,

thanks for the quick reply.  Yes I can add the web reference without errors, but I am changing it away from localhost as I am currently using the emulator, to paul-virtual the name of my client VM.

Cheers, Paul
0
 
Mikal613Commented:
yes localhost would not be a good idea. also make sure that you can see the server (or vm).

To test without running your app you can open PIE and open the web service. If you can see it then you should have no problems.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
fly12Author Commented:
Sorry,

Could you go into a bit more detail in your previous comment.  Just to make sure I have not left out any steps.

Cheers
0
 
Mikal613Commented:
open PIE (pocket internet explorer)

type in http:\\yoururl\yourwebservice.asmx and see if the HelloWorld method is there
0
 
fly12Author Commented:
If I cannot navigate to it, what might be possibly wrong?

I have attached my solution, if that helps.
0
 
Mikal613Commented:
right now just the Data access of your PDA
0
 
fly12Author Commented:
What is just Data access? I am new to this, so I do not know all the terms.

Thanks
0
 
fly12Author Commented:
Hi,

I have been looking at the web service.  It is still running as local host on my main machine.  Should this be changed to the machine name?  If so how?


0
 
Mikal613Commented:
in your project select your web reference and I believe you can change the url for the web service in the properties window.

what i mean by dataaccess is the way you connect to the internet. GPRS,edge,wifi...
0
 
fly12Author Commented:
Hi,  

Thanks for the quick response.  Yes I can change the URL, but when I change it to http://myMachineName/service1.asmx it throws up this error:
---------------------------
Microsoft Visual Studio
---------------------------
There was an error downloading 'http://paul-laptop:4400/Service1.asmx'.
---------------------------
OK  
---------------------------

SO i was therefore wondering if it was possible to change my web service away from local host, as if I browse for it in IE using http://machinename:portnum:service.asmx it does not load, until I have entered localhost instead.

I am using the visual studio emulator, and connecting via active sync 4.5 so it can use my machines connection.

Cheers, Paul
0
 
Mikal613Commented:
Try to enter the URL on your PDA not on your computer
0
 
fly12Author Commented:
Yeah I have been, just tried it on IE as well.

On PIE it throws up the following error message:

Your internet connection is not properly configured. Please verify your setting in connections.

I can surf to other pages on the www.
0
 
Mikal613Commented:
you can see google?
0
 
fly12Author Commented:
Yes I can see google
0
 
Mikal613Commented:
and when you put this url http://paul-laptop:4400/Service1.asmx in your pda what happens
0
 
fly12Author Commented:
It gives the message:

Your internet connection is not configured properly.  Please verify your settings in connections.

Cheers, Paul
0
 
Mikal613Commented:
take out the port number and what happens

http://paul-laptop/Service1.asmx
0
 
fly12Author Commented:
Same error, and I also took out the Service1.asmx and again the same error.

Cheers, Paul
0
 
Mikal613Commented:
how is your PDA connected  to the internet
0
 
fly12Author Commented:
As far as I am aware it is through the Active Sync 4.5, but I could be wrong.  As there a simple way to find out
0
 
Mikal613Commented:
so your pda is connected to your computer via usb?
0
 
fly12Author Commented:
It is an VS emulator, and i have changed the setting from within active sync to allow connections from DMA
0
 
Mikal613Commented:
0
 
fly12Author Commented:
Hi,

Yes the IP address is working.  Does that mean the phone cannot work out the DNS for phone is not working correctly?

Cheers, Paul
0
 
Mikal613Commented:
There is a bug with the DNS which means your gonna have to use the IP
0
 
fly12Author Commented:
Is this a known bug? Or just one with my app?
0
 
Mikal613Commented:
its a known one. Others have the same problem
0
 
fly12Author Commented:
Thats great, cheers for your help
0
 
Mikal613Commented:
np
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 15
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now