Skip to content

Instantly share code, notes, and snippets.

@aalinat
Created August 10, 2014 23:15
Show Gist options
  • Save aalinat/eb44cc7201e21e255c5e to your computer and use it in GitHub Desktop.
Save aalinat/eb44cc7201e21e255c5e to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
namespace TESTRestFulWCF
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Restful
{
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
public void DoWork()
{
// Add your operation implementation here
return;
}
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json)]
public string Hello()
{
return "Hello";
}
// Add more operations here and mark them with [OperationContract]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment