c# - Using a Wcf Service in web application -
i created wcf service library. there service1 , iservice1 class , 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 have added project , added service reference there , add text file named ajaxservice.svc
<%@ servicehost debug="true" factory="system.servicemodel.activation.webscriptservicehostfactory" language="c#" service="dataservices.service1" %>
but when running file in browser:
thank god. solved problem:
i have copied files target folder , paste them project.
copy "$(targetdir)*.dll" "$(projectdir)bin" copy "$(targetdir)*.pdb" "$(projectdir)bin" copy "$(targetdir)*.config" "$(projectdir)bin"
Comments
Post a Comment