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
- 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.
- Apply the «Service Contract» stereotype to the interface.
- On the Stereotypes page of the Properties view, under Stereotype
Properties, set the Service Contract properties
as required for your implementation.
- In the interface, add one or more UML operations.
- To each operation, apply the «Operation Contract» stereotype.
- Select an operation; on the Stereotypes page of the Properties
view, under Stereotype Properties, set the Operation
Contract properties as required for your implementation.
- Add a UML class in the diagram.
- 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.
What to do next
After modeling the service contract, you can
configure and run a UML-to-C# transformation to generate the C# code.