Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • REST attributes of WCF Service

    • 0
    • 4
    • 3
    • 1
    • 0
    • 0
    • 0
    • 0
    • 555
    Comment on it

    Objective: In this article we will explain what are the REST Attributes of WCF service and there usage.

    Here WCF Stands for Windows Communication Foundation

    1. WebServiceHost: This is a class which is inherited from ServiceHost Class. ServiceHost class is used to implement Windows Communication Foundation (WCF) REST programming model. WebServiceHost class do some extra tasks like disabling wsdl, Mex End point and prevents meta data publishing. It also creates end points automatically for all contracts. It adds behavior to all end point.

    2. WebHttpBinding: This class is inherited from Binding class. Binding class is used to configure end points for WCF web services which are exposed through HTTP request rather than SOAP. WebHttpBinding is used in web.config file to initialize binding type.

    3. WebHttpBehavior: This attribute provides the correct networking stack for using REST. WebHttpBehavior is the object that causes the URI-plus-verb dispatcher to be used, so the WebHttpBinding and the WebHttpBehavior are almost always used together.

    4. WebOperationContext: This class provides access to contextual properties of Web requests and responses. Usage: WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";

    5. WebMessageFormat: It specifies the format of the message. Usage: a. [WebGet(ResponseFormat= WebMessageFormat.Json)] b. [WebGet(ResponseFormat= WebMessageFormat.Xml)]

    6. WebGet: This attribute is sued to define a service operation

    Usage : [WebGet] public IQueryable GetOrdersByCity(string city)

    7 WebInvoke: This is an attribute which ensures that method is called by WCF REST programming model is logically invoke.

    Usage : [WebInvoke] public IQueryable GetOrdersByCity(string city)

    8 UriTemplate: UriTemplate is a class which have methods to match an incoming URI to a template, generate a URI from a template, retrieve a collection of variable names used in the template, determine whether two templates are equivalent, and return the template's string

    Usage: UriTemplate t = new UriTemplate("{shoe=1}/{boat=null}");

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: