开发者

consume/unit test forms validated restful webservice

I am using asp.net mvc to create forms validated restful webservices.

I am just wondering whether it is possible to consume these web services via, for example, a console application? How do I create the cookie etc.

Ultimately I would like to unit test the actual web 开发者_运维问答services.


I am just wondering whether it is possible to consume these web services via, for example, a console application?

certainly you can

Sample webservice

    [WebService(Namespace = "http://localhost/MyWebService/")]
    public class MyWebService : WebService
    {
        [WebMethod]
        public int Add(int a, int b)
        {
            return a + b;
        }

        [WebMethod]
        public String SayHello()
        {
            return "Hello World";
        }
    }

Here is how to consume it from a console application

  public static void Main(String[] args)
  {
      MyWebService  service = new MyWebService  ();
      mySvc.SayHello();          
      mySvc.Add(2, 3).ToString();
  }

see this article for detailed sample

.NET Web Services Tutorial

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜