Showing posts with label as. Show all posts
Showing posts with label as. Show all posts

Monday, October 3, 2016

How to create a web service ?



Step1: Create the Web Service

Open Visual Studio create new web site. File > New >Website

Add an item as Web Service to the project. Webservice.asmx

Now create some web methods 


 [WebMethod]
 public string GetbyId(string name){}


if the response is in Custom Created Class then return that class object as below
 
[WebMethod]
[System.Xml.Serialization.XmlInclude(typeof(Students))]
 public string GetAll(string name){}


Public Class Student
{
public string name{get; set;}
public string rollnumber{get; set;}
}

Step 2: Publishing the Web Service

To publish the web service the procedure is same as publishing the website because as we created the Web Service under Web Site Project.




Secure you Asp .NET by Web.config & Global.ascx?

Add to Global.ascx protected void Application_BeginRequest(object sender,EventArgs e)     {         //to remove x frame         Resp...