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.

Answers


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


Need Your Help

MVP Passive View - Where to wire up the view's events?

c# mvp

I used to simply just have an ApplyPresenter() method on my view, but technically that is not passive view if the view knows about the presenter and calls methods on it.

asp.net mvc getting id from url

asp.net-mvc

ok i have a create/Index/23 view . the create method in the index controller is getting the value of the id when the dropdown event is triggered in the grid. no problem

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.