Link to home
Start Free TrialLog in
Avatar of fly12
fly12

asked on

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

Avatar of Mikal613
Mikal613
Flag of United States of America image

were you able to add the web reference without errors?
Avatar of fly12
fly12

ASKER

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
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.
Avatar of fly12

ASKER

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
open PIE (pocket internet explorer)

type in http:\\yoururl\yourwebservice.asmx and see if the HelloWorld method is there
Avatar of fly12

ASKER

If I cannot navigate to it, what might be possibly wrong?

I have attached my solution, if that helps.
right now just the Data access of your PDA
Avatar of fly12

ASKER

What is just Data access? I am new to this, so I do not know all the terms.

Thanks
Avatar of fly12

ASKER

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?


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...
Avatar of fly12

ASKER

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
Try to enter the URL on your PDA not on your computer
Avatar of fly12

ASKER

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.
you can see google?
Avatar of fly12

ASKER

Yes I can see google
and when you put this url http://paul-laptop:4400/Service1.asmx in your pda what happens
Avatar of fly12

ASKER

It gives the message:

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

Cheers, Paul
take out the port number and what happens

http://paul-laptop/Service1.asmx
Avatar of fly12

ASKER

Same error, and I also took out the Service1.asmx and again the same error.

Cheers, Paul
how is your PDA connected  to the internet
Avatar of fly12

ASKER

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
so your pda is connected to your computer via usb?
Avatar of fly12

ASKER

It is an VS emulator, and i have changed the setting from within active sync to allow connections from DMA
Avatar of fly12

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fly12

ASKER

Is this a known bug? Or just one with my app?
its a known one. Others have the same problem
Avatar of fly12

ASKER

Thats great, cheers for your help