web-serviceswindows-phone-7smart-devicesmart-device-framework

How To Use WebService In Windows Smart Phone 6?


I am Developing one Windows Smart Phone - 6 Application using C# in .Net 3.5 Framework. And I have created one Webservice project using ASP.Net Web Service Application 3.5. Into this Webservice project I have define Service1.asmx. Now I would like to call Webmethod "HelloWorld" on Button Click. Here is code.

Service1.asmx

using System.Web.Services;

namespace WebService1
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
}

And Button Click Event

    private void button1_Click(object sender, EventArgs e)
    {
        WebService1.Service1 myService = new WebService1.Service1();
        string str = myService.HelloWorld();
    }

I am Getting Error On This Line

WebService1.Service1 myService = new WebService1.Service1();

Please Give Me Guidance As I am Very New In This.

Thanks In Advance

Pratik Bhatt


Solution

  • Problem Solved.

    Error Was Occurring Because The Smart Device Emulator has No Access Permission for internet(network)so you have to install Microsoft Active Sync to connect emulator to network

    Thanks Ralf Ehlert For Suggesting.....