2
Reply

How to make a method of a web service class accessible through the internet?

Purushottam Rathore

Purushottam Rathore

Mar 03, 2011
6.1k
0

    First create asmx class file and in that file write this below code web service method ///

    /// Summary description for CommonWebService/// [WebService(Namespace = "http://microsoft.com/webservices/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.ComponentModel.ToolboxItem(false)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService]public class CommonWebService : System.Web.Services.WebService{BaseBL objBaseBL = new BaseBL();public CommonWebService(){//Uncomment the following line if using designed components//InitializeComponent();}//Retrieve record or fetch data on Enitity name and field name[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]public string RetrieveRecordExists(string name, string entity){string result = "";DataSet ds = new DataSet();ds = objBaseBL.RetrieveRecordExists(name, entity);if (ds != null){result = ReturnJson.GetJson(ds);}return result;} }/// call this method with java script and jason

    Milind bilonia
    June 11, 2016
    0

    By qualifying the method with the WebMethod attribute.

    For Example:
     
    C#
        [WebMethod()]
       
    public string MethodName()
     
    VB
       
    <WebMethod()> _
       
    Public Function MethodName() As String

    Purushottam Rathore
    March 03, 2011
    0