Modeling WCF service contracts

You can model a Windows Communication Foundation (WCF) service contract to generate C# code for a service.

Before you begin

To use the stereotypes required in this procedure, you must apply the .Net WCF profile to the model.

About this task

To model a WCF service contract in a diagram:

Procedure

  1. Add a UML interface in the diagram. Optionally, you can add a UML class instead of an interface. Classes can also act as service contracts.
  2. Apply the «Service Contract» stereotype to the interface.
  3. On the Stereotypes page of the Properties view, under Stereotype Properties, set the Service Contract properties as required for your implementation.
  4. In the interface, add one or more UML operations.
  5. To each operation, apply the «Operation Contract» stereotype.
  6. Select an operation; on the Stereotypes page of the Properties view, under Stereotype Properties, set the Operation Contract properties as required for your implementation.
  7. Add a UML class in the diagram.
  8. Add a realization relationship from the class to the interface.

Example

The following image shows a sample diagram of a class implementing a WCF service contract.
Diagram view of a WCF service contract.

What to do next

After modeling the service contract, you can configure and run a UML-to-C# transformation to generate the C# code.

Feedback