Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created a simple webservice for multiplication in VS2012 where x*y gives the product.to consume it in the webpage i follwed this procedure:
*right click on webapp->add service reference->advanced->add web reference->add refernce.

i left web reference name as localhost.
after this under WEB reference,localhost alone gets created and thats it! the subfiles that must be generated under localhost i.e. the service and it's .disco,.wsdl does not get created.and could not run this simple consumption of webservce.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace websiteformyfirstwebservice
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            localhost.Service1 o = new localhost.Service1();
            int a = int.Parse(TextBox1.Text.ToString());
            int b = int.Parse(TextBox2.Text.ToString());
            int x = o.Multiply(a, b);
            Label1.Text = "The Result is" + x.ToString();
        }
    }
}


but an error occurs showing->

Error 1 'websiteformyfirstwebservice.localhost.Service1' does not contain a definition for 'Multiply' and no extension method 'Multiply' accepting a first argument of type 'websiteformyfirstwebservice.localhost.Service1' could be found (are you missing a using directive or an assembly reference?) D:\Personels\myfirstwebservice\websiteformyfirstwebservice\Default.aspx.cs 22 23 websiteformyfirstwebservice



someone please help me i am exhausted trying to solve this every time.
Thanx in advance!
Posted
Updated 22-Sep-14 6:59am
v3

1 solution

put Following Code as

localhost.WebService1 objLogin = new localhost.WebService1();


WHERE localhost is REFERENCE NAME

WebService1 is ClassName of Your Service

Now you access any Method of Your Service Class Through Object
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900