Export (0) Print
Expand All

How to: Expose a REST-based Web Service Through Service Bus

Updated: January 7, 2015

Exposing a REST-based service with Service Bus requires no special steps beyond what is required to make any Windows Communication Foundation (WCF) service REST-based. The main change is the addition of a series of attributes to the contract definition that map the contract operations to commands in the REST protocol. Note that these attributes are WCF attributes; the ability to define an interface as REST-compliant is an aspect of WCF, instead of anything specific to Service Bus. Thus, the following is a simplified procedure for tagging a contract to be REST-compliant. For a complete discussion, see WCF REST Programming Model in the WCF documentation.

  1. Define a standard Service Bus contract, as shown in the topic How to: Design a WCF Service Contract for use with Service Bus.

  2. When defining the service contract with the OperationContractAttribute attribute, use one of the following values to indicate how the member maps to the REST protocol:



    [OperationContract, WebGet] or [OperationContract]




    [WebInvoke(Method = “PUT”)]



    [WebInvoke(Method = “DELETE”)]




    The following example shows how to tag an interface member as a REST-style GET member.

    public interface ImageContract
        [OperationContract, WebGet]
        Message GetImage();
  3. If you are designing a service, implement the contract as a class elsewhere in your project.

© 2015 Microsoft