Created
August 10, 2014 23:15
-
-
Save aalinat/9eebcf4e795d92699e93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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