We help IT Professionals succeed at work.

Using Web Services from a mobile Device

fly12
fly12 asked
on
Medium Priority
1,323 Views
Last Modified: 2013-12-05
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

Comment
Watch Question

CERTIFIED EXPERT

Commented:
were you able to add the web reference without errors?

Author

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
CERTIFIED EXPERT

Commented:
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.

Author

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
CERTIFIED EXPERT

Commented:
open PIE (pocket internet explorer)

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

Author

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

I have attached my solution, if that helps.
CERTIFIED EXPERT

Commented:
right now just the Data access of your PDA

Author

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

Thanks

Author

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?


CERTIFIED EXPERT

Commented:
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...

Author

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
CERTIFIED EXPERT

Commented:
Try to enter the URL on your PDA not on your computer

Author

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.
CERTIFIED EXPERT

Commented:
you can see google?

Author

Commented:
Yes I can see google
CERTIFIED EXPERT

Commented:
and when you put this url http://paul-laptop:4400/Service1.asmx in your pda what happens

Author

Commented:
It gives the message:

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

Cheers, Paul
CERTIFIED EXPERT

Commented:
take out the port number and what happens

http://paul-laptop/Service1.asmx

Author

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

Cheers, Paul
CERTIFIED EXPERT

Commented:
how is your PDA connected  to the internet

Author

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
CERTIFIED EXPERT

Commented:
so your pda is connected to your computer via usb?

Author

Commented:
It is an VS emulator, and i have changed the setting from within active sync to allow connections from DMA
CERTIFIED EXPERT

Commented:

Author

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
CERTIFIED EXPERT
Commented:
There is a bug with the DNS which means your gonna have to use the IP

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Is this a known bug? Or just one with my app?
CERTIFIED EXPERT

Commented:
its a known one. Others have the same problem

Author

Commented:
Thats great, cheers for your help
CERTIFIED EXPERT

Commented:
np
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.