How to create web service (server & Client) in Visual Studio 2012?

后端 未结 4 551
南旧
南旧 2021-02-02 08:16

How to create web service (server & Client) in Visual Studio 2012? like being done before 2012 as http://www.tutorialspoint.com/asp.net/asp.net_web_services.htm

4条回答
  •  伪装坚强ぢ
    2021-02-02 08:31

    WCF is a newer technology that is a viable alternative in many instances. ASP is great and works well, but I personally prefer WCF. And you can do it in .Net 4.5.

    WCF Project

    enter image description here

    Create a new project. enter image description here Right-Click on the project in solution explorer, select "Add Service Reference" enter image description here

    Create a textbox and button in the new application. Below is my click event for the button:

    private void btnGo_Click(object sender, EventArgs e)
        {
            ServiceReference1.Service1Client testClient = new ServiceReference1.Service1Client();
            //Add error handling, null checks, etc...
            int iValue = int.Parse(txtInput.Text);
            string sResult = testClient.GetData(iValue).ToString();
            MessageBox.Show(sResult);
        }
    

    And you're done. enter image description here

提交回复
热议问题