Can I call a webservice from a Controller Action in ASP.Net MVC?
publ开发者_开发技巧ic ActionResult Index()
{
    PersonObject person = new Person("Sam");
    //Call a webservice which is located in the same app under /Services/General.asmx/WebMethod and pass it person
}
Basically I want to do this from my Action...
             $.ajax({
                    type: "POST",
                    url: "/Services/General.asmx/WebMethod",
                    data: JSON.stringify(DTOInternetPricing),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(res) {
                    },
                    error: function(res) {
                    }
                });
If the web service is part of the same application you may not need to call it as a web service at all, you could just use it's classes as normal objects, methods, etc. ie just call the logic directly through code.
In order to call a web service in C# you need to generate a client proxy from the WSDL. You need to add a service reference and use the generated proxy to consume the service.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论