Wednesday, February 11, 2015

Create an ASMX web service from a WSDL file

If you already created interfaces you need to implement those interfaces.
Just create new web service and add interface that you generated so that it inherits that interface. Visual Studio can automatically generate stubs for every method in interface. Mark them with WebMethod attribute and put some code that will return some test data/results.
If you got inteface (with some more attributes that were automatically generated:

public interface IRealWebService
{
    string GetName();

}
You should make new service:

public class WebTestService : System.Web.Services.WebService, IRealWebService
{

    #region IRealWebService Members

    [WebMethod]
    public string GetName()
    {
     return "It Works !!!!";
    }
    #endregion
}

No comments:

Post a Comment