Transforming REST models into RESTful WCF service library code

You can generate code that is compatible with the REST Windows Communication Foundation (WCF) service library by applying stereotypes from the Representational State Transfer (REST) and .NET Windows Communication Foundation (WCF) profiles to elements in a REST model.

Before you begin

You must have the REST modeling capability enabled.

To generate WCF service library code, your REST model must have at least one class or interface that has the «Resource» stereotype applied. To model REST-specific WCF attributes, other than the «Resource» stereotype, you must also use the «ServiceContract» stereotype.


  1. To create a model project and a model from the REST Service Model template, complete the following steps:
    1. Click File > New > Model Project, and complete the pages in the Model Project wizard
    2. On the Create Model page of the wizard, in the Categories pane, click REST Modeling, then in the Templates pane, click REST Service Model.
    3. Optional: Complete the remaining pages in the wizard.
    4. Click Finish. The modeling project is displayed in the Project Explorer view and the model has theREST profile applied.
  2. In the model, create an interface or a class and apply the «Resource» stereotype, which is in the REST profile. To create a model with the REST-specific WCF attributes, other than the «Resource» stereotype, also apply the «ServiceContract» stereotype.
  3. Create a UML-to-C# or C#-to-UML transformation configuration: Click File > New > Transformation Configuration, and complete the steps in the wizard. Specify the following values in the transformation configuration file:
    1. On the Specify a Configuration Name and Transformation page, in the Protocol field, select Reconciled.
    2. On the Extensions page, for each transformation select the check box that corresponds to the REST support extension.
    3. On the WCF REST page, select the Route table generation information check box to specify the parameters for generating the route table in the UML-to-C# transformation or in the C#-to-UML transformation, for extracting the information from the method of the class that you specify in the Method for generation of route table field, and for generating path dependencies in the UML model.
    4. On the same WCF REST page, click Generate REST stereotypes only to apply only the REST stereotypes on the reverse transformation. Alternatively, if you want to apply both the WCF and REST stereotypes, click Generate both REST and WCF stereotypes. By selecting any of these options for generating stereotypes, you can resolve the conflict of identical information in a model element where both the REST and WCF stereotypes are applied.
  4. Click File > Save.

What to do next

You can now run the transformation. For information about running transformations, see the related link at the end of this topic.