Question

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

Was it helpful?

Solution 2

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

OTHER TIPS

Use the add web reference dialog from visual studio and point them to your hosted service. The dialog creates the consuming client based on the generated WSDL.

Your approach doesn't work because hosting a webservice and consuming one uses a different set of classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top