我在网站项目中创建了一个Web服务(在vs 2010中)。在visual studio中,当我运行这个网站时,我可以看到这个Web服务,如下所示:
网络服务的主体是:
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public int Plus(int x, int y)
{
return x + y;
}
[WebMethod]
public int Multiply(int x, int y)
{
return x * y;
}
}
我通过以下步骤在iis 6上托管此网站:
1)右键单击WebSites节点,单击“添加新网站”选项 IIS。
2)为它分配一个端口(对于ex 1919端口)
3)在下一步中指定网站的物理路径
4)指定访问级别权限
5)完成
现在我想调用以下地址,并给出此错误:
我重启iis,没有发生任何事情。
我想在本地使用此Web服务,为什么会出现此错误?怎么解决呢?
答案 0 :(得分:1)
创建虚拟目录时选中“执行(例如ISAPI应用程序或CGI)”复选框
答案 1 :(得分:1)
您可能只需要启用.NET Web Extensions。见图。
如果没有,请确保将webservice所在的目录标记为应用程序,并设置为execute。还要确保通过运行
来设置asmx处理程序C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -ir