在IIS6上部署WebService

在IIS6上部署WebService

2016-12-07

目录:

1 创建web service项目
2 部署WebService
3 浏览页面

1 创建web service项目


 返回 

用Visual Studio模板“ASP.NET Web 服务应用程序”新建项目。

其它不变,只增加WebMethod Add方法,如下图1所示 

图1 创建Web Service项目

把WebService1.dll放在目录D:StudyWebSericein下,把Service1.asmx和Web.config放在目录D:StudyWebSerice下,代码如下:

Service1.asmx.cs代码:

using System.Web.Services;

namespace WebService1
{
    /// <summary>
    /// 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 float Add(float a,float b)
        {
            return a + b;
        }
    }
}

Service1.asmx代码:

<%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="WebService1.Service1" %>

Web.config代码:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <appSettings/>
    <connectionStrings/>
    <system.web>
        <compilation debug="true" >

        </compilation>
    <!--
      通过 <authentication> 节,可配置 
      ASP.NET 用于识别进入用户的 
      安全身份验证模式。
    -->
    <authentication mode="Windows" />
    <!--
       通过 <customErrors> 节,可以配置
       在执行请求的过程中出现未处理的错误时要执行 
       的操作。具体而言,
       开发人员通过该节可配置要显示的 html 错误页,
       以代替错误堆栈跟踪。

       <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
         <error statusCode="403" redirect="NoAccess.htm" />
         <error statusCode="404" redirect="FileNotFound.htm" />
       </customErrors>
    -->
    </system.web>

</configuration>

2 部署WebService


 返回

部署跟 在IIS6上部署aspx网站中的部署一致

3 浏览页面


 返回

进入Add页面,输入参数后可以调用add方法

原文地址:https://www.cnblogs.com/Ming8006/p/6140008.html