jasonjiang

服务端:要发布到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();

    }

分类:

技术点:

相关文章:

  • 2021-06-28
  • 2021-04-14
  • 2021-11-07
  • 2021-11-05
  • 2021-12-01
  • 2021-08-08
  • 2018-05-23
猜你喜欢
  • 2021-11-21
  • 2021-09-10
  • 2021-10-16
  • 2021-12-01
  • 2021-08-29
  • 2021-05-30
  • 2021-04-03
相关资源
相似解决方案