webservice的简单介绍

本文介绍了一个简单的 .NET WebService 实现案例,使用 C# 编程语言,并通过 Service1 类展示了如何定义 Web 方法 HelloWorld,该方法返回字符串 'HelloWorld'。此外,还提供了 WebService 的配置代码,包括命名空间定义、SOAP 文档服务属性等。

Web Services技术的组成要素

¢WSDL
¢SOAP
¢UDDI
 
.NET Web Service的实现
Service1.cs 

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Data;
using System.Web.Services.Protocols;
using System.Web.Services.Description;
using Microsoft.ApplicationBlocks.ExceptionManagement;
using System.Configuration;
using System.Net;


[WebService(Namespace = "http://www.1111.com")]
//[System.Xml.Serialization.SoapIncludeAttribute(typeof(PropertyData))]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[SoapDocumentService(SoapBindingUse.Literal,
                         SoapParameterStyle.Wrapped,
                         RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
public class Service1 : System.Web.Services.WebService
{

        [WebMethod]

        public string HelloWorld()

        {

            return "Hello World";

        }

    }

 

调用

 Service1.asmx

<%@ WebService Language="C#" CodeBehind="~/App_Code/Service1.cs" class="Service1" %>

 

 

转载于:https://www.cnblogs.com/linzheng/archive/2010/09/14/1826369.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值