I created a Wcf Service Library. There are Service1 and IService1 class and interface in it.
Service:
public class Service1 : IService1
{
public string InsertData(string Name, string Email, string Message)
{
XDocument xDoc = XDocument.Load(HttpContext.Current.Server.MapPath("DataFile.xml"));
xDoc.Element("Users").Add(
new XElement("User",
new XAttribute("Name", Name),
new XAttribute("Email", Email),
new XAttribute("Message", Message)));
xDoc.Save(HttpContext.Current.Server.MapPath("DataFile.xml"));
return "Registered Successfully";
}
}
Iservice:
[ServiceContract]
public interface IService1
{
[OperationContract]
string InsertData(string Name, string Email, string Message);
}
I followed this article. After this i have added an another project and added Service reference there and add text file as named AjaxService.svc
<%@ ServiceHost Debug="true" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" Language="C#" Service="DataServices.Service1" %>
But when i am running this file in the browser: