In this article, I'll show you how to use Developer Command Promt for VS 2017 to generate a web service to c# code by using the wsdl.exe (Web Services Description Language) tool.

generate webservice using wsdl to c# code

First you need to run Developer Command Promt for VS 2017 tool with Administrator mode, then type cd to move your root directory. This will make it easy to find generated files, then type wsdl your link web service, finally press enter to generate your web service to file.

You can see CustomerService.cs file in your root directory->Copy the CustomerService.cs file to your project, then open it and add a namespace as same as your project namespace.

Get back the tutorial How to call a Web Service in Windows Form Application, then modify your code as the following and don't forget add a reference to System.Web.Services.dll

private void btnHelloWorld_Click(object sender, EventArgs e)
{
    CustomerService service = new CustomerService();
    MessageBox.Show(service.HelloWorld(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void btnLoad_Click(object sender, EventArgs e)
{
    CustomerService service = new CustomerService();
    Customer[] customers = service.GetAll();
    customerBindingSource.DataSource = customers;
}