Winfrom版的WebService

1、找到一个提供webservice的网站,比如http://www.webxml.com.cn/zh_cn/index.aspx

找到一个web服务如http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx

2、新建一个WinFrom项目,解决方案资源管理器—引用—添加服务引用

单机高级,打开:

单机添加Web引用,打开:

输入一个服务地址如:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx

单机添加引用

之后:

前台阶面

后台代码:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsAppWebService

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            MobileWebService.MobileCodeWS mcws = new MobileWebService.MobileCodeWS();

            string msg = mcws.getMobileCodeInfo(textBox1.Text, "");

            label1.Text = msg;

        }

    }

}

 

原文地址:https://www.cnblogs.com/rongxiaoya/p/2634804.html