需要有关将webservice添加到.aspx页面的帮助! [英] need help regarding adding webservice to .aspx page!
问题描述
我在VS2012中为乘法创建了一个简单的web服务,其中x * y给出了product.to在网页中使用它我按照以下步骤:
*右键单击webapp-> add服务参考 - >高级 - >添加网络参考 - >添加推荐。
i将网络参考名称保留为localhost。
after在WEB引用下,仅创建了localhost就可以了!必须在localhost下生成的子文件,即服务,它的.disco,.wsdl不会被创建。并且无法运行这种简单的webservce消费。
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.
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();
}
}
}
但是出现错误 - >
错误1'websiteformyfirstwebservice.localhost.Service1'不包含'Multiply'的定义,也没有扩展方法'Multiply'接受'websiteformyfirstwebservice.localhost.Service1'类型的第一个参数可以找到(你错过了使用指令或程序集引用吗?)D:\ Personels \ myfirstwebservice \websiteformyfirstwebservice \Default.aspx.cs 22 23 websiteformyfirstwebservice
有人请帮助我我每次都试着解决这个问题。
提前完成!
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!
推荐答案
将以下代码作为
put Following Code as
localhost.WebService1 objLogin = new localhost.WebService1();
WHERE localhost为REFERENCE NAME
WebService1为C lassName of your service
现在您可以通过对象访问任何服务类方法
WHERE localhost is REFERENCE NAME
WebService1 is ClassName of Your Service
Now you access any Method of Your Service Class Through Object
这篇关于需要有关将webservice添加到.aspx页面的帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!