zoukankan      html  css  js  c++  java
  • Web Service 简单实现的例子

    服务端:要发布到IIS上

      public class User : SoapHeader

      {

        private string username;

        private string password;

        public string UserName

        {

          get{return username;}

          set{username = value;}

        }

        

        public string PassWord

        {

          get{return password;}

          set{password= value;}

        }

      }

      public class Service : WebService

      {

        User u =null;

        public Service()

        {}

        

        [WebMethod]

        public string HelloWorld()

        {

          return "Hello World";

        }

        [SoapHeader]

        [WebMethod]

        public string GetUser()

        {

          if(u.UserName == "aa" && u.PassWord == "123")

          {

             return "Good Morning!";

          }

          else

          {

             return "";

          }

        }

      }

    客户端:用Web页面调用

      1.先添加Web引用

      2.在页面放3个TextBox 用来输入用户名、密码和显示调用的结果,再放一个Button,当点击Button时调用

      3.后台主要代码:

        localhost.Server server = new localhost.Server();

        localhost.User u = new localhost.User();

        protected void Button1_Click(object sender, EventArgs e)

        {

          u.UserName ="aa";

          u.PassWord = "123";

          server.UserValue = u;

          this.textbox3.text = server.GetUser();

        }

  • 相关阅读:
    HDFS原理分析之HA机制:avatarnode原理
    [转]Hessian——轻量级远程调用方案
    [转]成为Java顶尖程序员 ,看这11本书就够了
    [转]Java四种线程池的使用
    [转]Java多线程
    IntelliJ IDEA 快捷键
    [转]django 日志logging的配置以及处理
    [转]使用TortoiseGit处理代码冲突
    动软DbHelperSQL
    [转]Entity Framework 的实体关系
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763479.html
Copyright © 2011-2022 走看看