加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

一个简单的WebService服务

发布时间:2020-12-17 02:53:16 所属栏目:安全 来源:网络整理
导读:server1.asm代码清单如下: using System; using System.Data; using System.Data.SqlClient; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.ComponentModel; using System.Co

server1.asm代码清单如下:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Configuration;

namespace SecurityWebService
{
??? /// <summary>
??? /// Service1 的摘要说明
??? /// </summary>
??? [WebService(Namespace = "http://tempuri.org/")]
??? [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
??? [ToolboxItem(false)]
??? public class Service1 : System.Web.Services.WebService
??? {

??????? [WebMethod]
??????? public int Add(int a,int b)
??????? {
??????????? return a + b;
??????? }
??????? [WebMethod]
??????? public string Fdk()
??????? {
??????????? return "asd";
??????? }
??????? [WebMethod]
??????? public string HelloWorld()
??????? {
??????????? return "Hello World";
??????? }
??????? [WebMethod]
??????? public DataSet GetInfo()
??????? {
??????????? return Getds("Select * From MtmCompanyIntro");
??????? }

??????? public DataSet Getds(string sSQL)
??????? {
??????????? string sConnection = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
??????????? SqlConnection conn;
??????????? conn = new SqlConnection(sConnection);
??????????? conn.Open();

??????????? SqlCommand myCMD = new SqlCommand(sSQL,conn);
??????????? SqlDataAdapter myda = new SqlDataAdapter();
??????????? myda.SelectCommand = myCMD;
??????????? DataSet myDs = new DataSet();
??????????? myda.Fill(myDs,"mds");
??????????? conn.Close();
??????????? return myDs;
??????? }

??? }}?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读