如何从C#控制台应用程序调用Web服务

如何从C#控制台应用程序调用Web服务

问题描述:

我在asp.net MVC web api中有这个简单的类:



i have this simple class in an asp.net MVC web api:

public class OrdersController : ApiController
    {
        // GET api/orders
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // POST api/orders
        [HttpPost]
        public void Post([FromBody]string value)
        {
        }

        
    }





转到此网址: http:// localhost:55186 / api / orders [ ^ ]



返回:



going to this url: http://localhost:55186/api/orders[^]

returns:

<ArrayOfstring>
    <string>value1</string>
    <string>value2</string>
</ArrayOfstring>





如何在C#控制台应用程序中调用post方法?



谢谢,

Gabriel Sas



how can i call the post method in C# console application?

Thanks,
Gabriel Sas

检查这些:

如何:调用Web服务 [ ^ ]

C#中的Web服务简介 [ ^ ]

Web Services C Sharp .NET端到端教程 [ ^ ]
Check these:
How to: Call a Web Service[^]
Introduction to Web Services in C#[^]
Web Services C Sharp .NET End to End Tutorial[^]