Modeling WCF data contracts

You can model a Windows Communication Foundation (WCF) data contract.

Before you begin

To use the stereotypes required in this procedure, you must apply the .Net WCF profile to the model. The C# transformation profile is optional for creating C# structs.

About this task

To model a WCF data contract in a diagram:

Procedure

  1. Add a UML class in the diagram.
  2. Apply the «Data Contract» stereotype to the class. Optionally, to create a C# struct, also apply the «CSharp Struct» stereotype to the class.
  3. On the Stereotypes page of the Properties view, under Stereotype Properties, set the data contract properties as required for your implementation.
  4. In the class, add one or more UML attributes.
  5. To each attribute you want serialized, apply the «Data Member» stereotype.
  6. Select a serialized attribute; on the Stereotypes page of the Properties view, under Stereotype Properties, set the Data Member properties as required for your implementation.

Example

The following image shows a sample diagram of a data contract.
Diagram view of a WCF data contract.

The following screen capture shows the stereotype properties for data contract in the Properties view.

In the Properties view, the Namespace stereotype property for the data contract stereotype is set to an Internet address.

What to do next

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

Feedback