Hi,I think that Most of us know the Webservice,this is for to those who are not familiar with the Webservices.
Create a new Project and select Add New WebService in New Project Template .
Create a New Service.asmx File for your Webservice. You ll get a default method in your Code behind file of Service.asmx .i.e)Hello World Method
Service.cs ================
using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () {
//Uncomment the following line if using designed components //InitializeComponent(); }
[WebMethod] public string HelloWorld() { return "Hello World"; } }
After writing the Service Press F5 to run this service. You ll get a result page with your method name,after clicking the method name(Hello World) you ll redirect to a page. Just copy that URL from ur browser for eg:(http://localhost:1849/SampleService/Service.asmx?op=HelloWorld) ,which ll be used in your Application
Now the Web Service Creation ll be over
Next Step: Creata a New Asp.net Web Application,Right Click From your Solution Explorer,Click on Add new WebReference folder,You ll get a template and just paste ur Service URL in that addressbar and click on OK button.
Service Related Files ll be added in your Project.Now create a new webForm,and In your codebehind, Include the namespace for Your Service,and create object for your Service Class and call ur method,For eg:
Check.cs =================
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using localhost;//this is your service namespace
public partial class Check : System.Web.UI.Page { Service ser = new Service(); protected void Page_Load(object sender, EventArgs e) { Response.Write(ser.HelloWorld());//You ll get a "HelloWorld " string as a result. }
}
|
No responses found. Be the first to respond and make money from revenue sharing program.
|