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();

        }

  • 相关阅读:
    eclipse中的debug模式的使用
    Hibernate快速入门
    鸟哥的 Linux 私房菜Shell Scripts篇(四)
    Vim命令图解及快捷键讲解
    SpringBoot文档
    鸟哥的 Linux 私房菜Shell Scripts篇(三)
    鸟哥的 Linux 私房菜Shell Scripts篇(二)
    (二)IDEA使用,快捷键
    (一)IDEA使用,基础配置
    idea-git同步服务器代码后撤销操作
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763479.html
Copyright © 2011-2022 走看看