
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 0.71 KB | hits: 17 | expires: Never
Simplest way to expose a JSON service in ASP.NET / DotNetNuke
<%@ ServiceHost
Service="MyNamespace.MyService"
Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
public class MyService : IMyService
{
public string Test(string text)
{
return text; // whatever
}
}
[ServiceContractAttribute(Namespace="http://schemas.myservice.com")]
public interface IMyService
{
[OperationContractAttribute]
[WebInvokeAttribute(UriTemplate="Test", // change this accordingly
ResponseFormat=WebMessageFormat.Json, // change this accordingly
RequestFormat=WebMessageFormat.Json, // change this accordingly
BodyStyle=Wrapped)]
string Test(string text);
}