Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Simplest way to expose a JSON service in ASP.NET / DotNetNuke
  2. <%@ ServiceHost
  3.  Service="MyNamespace.MyService"
  4.  Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
  5.        
  6. public class MyService : IMyService
  7. {
  8.         public string Test(string text)
  9.         {
  10.             return text; // whatever
  11.         }
  12.  
  13. }
  14.  
  15. [ServiceContractAttribute(Namespace="http://schemas.myservice.com")]
  16. public interface IMyService
  17. {
  18.     [OperationContractAttribute]
  19.     [WebInvokeAttribute(UriTemplate="Test", // change this accordingly
  20.      ResponseFormat=WebMessageFormat.Json, // change this accordingly
  21.      RequestFormat=WebMessageFormat.Json, // change this accordingly
  22.      BodyStyle=Wrapped)]
  23.     string Test(string text);
  24. }