如何在Visual Studio 2012中创建Web服务(服务器和客户端)?

时间:2012-08-21 09:21:12

标签: web-services

如何在Visual Studio 2012中创建Web服务(服务器和客户端)? 喜欢在2012年之前完成 http://www.tutorialspoint.com/asp.net/asp.net_web_services.htm

4 个答案:

答案 0 :(得分:105)

在您选择的语言下创建新项目时,选择 Web ,然后更改为 .NET Framework 3.5 ,您将可以选择创建 ASP.NET WEB服务应用程序

enter image description here

答案 1 :(得分:32)

  1. 创建一个新的空Asp.NET Web应用程序。
  2. 解决方案资源管理器右键单击项目根目录。
  3. 选择菜单项Add->网络服务

答案 2 :(得分:11)

WCF是一种新技术,在许多情况下是一种可行的替代方案。 ASP很棒并且运行良好,但我个人更喜欢WCF。你可以在.Net 4.5中完成。

WCF Project

enter image description here

创建一个新项目。 enter image description here 右键单击解决方案资源管理器中的项目,选择“添加服务引用” enter image description here

在新应用程序中创建一个文本框和按钮。以下是按钮的点击事件:

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

你已经完成了。 enter image description here

答案 3 :(得分:2)

---创建一个ws服务器 vs2012 upd 3

  1. 新项目

  2. 选择.net framework 3.5

  3. asp.net网络服务应用程序

  4. 右键单击项目根目录

  5. 选择添加服务参考

  6. 选择wsdl

  7. ---如何从wsdl文件创建ws客户端?

    我在tomcat 7下有一个服务器Axis2,我想测试兼容性