IBM Rational Modeling Extension with Microsoft Visual Studio 2008 and .NET Framework 3.0 support

IBM Rational Modeling Extension for Microsoft .NET for IBM Rational Software Architect Standard Edition or IBM Rational Software Modeler provides application modeling and code generation in the C# language. The integration with Microsoft Visual Studio 2008 means that developers can use it with the 2005 version of Visual Studio, too. It also supports the Microsoft .NET framework 3.0 Microsoft Windows Communication Foundation (WCF) service modeling and code generation.


Manoj Paul (, Sysytem Software Engineer, IBM India

Manoj PaulManoj Paul is a systems software engineer in the IBM Rational software lab in Bangalore, India, where he works for the Rational Software Architect team. He is involved in the development of the Rational Modeling Extension for Microsoft .NET support.

Manish Paul (, Senior Staff Software Engineer, IBM India

Manish PaulManish Paul is a senior staff software engineer in the IBM Rational software lab in Bangalore, India. As part of the Rational Software Architect team, he is working on the development of the Rational Modeling Extension for Microsoft .NET support.

10 August 2009

Also available in Chinese Portuguese

IBM® Rational® Modeling Extension for Microsoft® .NET enables .NET application developers to use Rational modeling tools in designing applications. This extension is available in IBM® Rational® Software Modeler and IBM® Rational® Software Architect Standard Edition, and it includes support for modeling C# applications and subsequent code generation.

Rational Modeling Extension for Microsoft .NET provides a way in which you can work with Microsoft® Visual Studio® projects within Rational Software Architect Standard Edition (or Rational Software Modeler). By using this extension, you can visually design your .NET applications in Unified Modeling Language (UML), and then use transformations to generate code into Visual Studio projects. A solution in Visual Studio is maintained as a linked resource in the Rational Software Architect Standard Edition (or Rational Software Modeler) workspace. This modeling extension can now be used with both Microsoft Visual Studio 2005 and Microsoft Visual Studio 2008, and solutions from either of the Microsoft offerings can be imported into Rational Software Architect or Rational Software Modeler and used for code generation.

Microsoft .NET Framework 3.0 introduces several new application programming interfaces for building and running the next generation of applications and XML Web services. These include the following Microsoft® Windows® options:

  • Windows Presentation Foundation (WPF)
  • Windows Communications Foundation (WCF)
  • Windows Workflow Foundation (WF)

As an initiative toward supporting .NET 3.0 framework, Rational Modeling Extension for Microsoft .NET allows modeling of services with sets of predefined WCF stereotypes and subsequent code generation with the round-trip engineering support. This enables modeling a service in a Rational Software Architect environment and generating the deployable C# code for the services.

Visual Studio 2008 integration

The integration with Microsoft Visual Studio 2008 means that you can import .NET solutions from Visual Studio 2008 into the Rational Software Architect SE workspace as linked resources and use available projects as a target for code generation. In a nutshell, you can use Visual Studio 2008 in the same way that Rational Modeling Extension was used in conjunction with Visual Studio 2005. The default integrated development environment (IDE) that Rational Software Architect SE looks for is Visual Studio 2005. As Figure 1 shows, you can change the preference to importing Visual Studio 2008 by selecting Windows > Preferences > Modeling > .Net Modeling. After the designated IDE is set in the Preferences page, Rational Modeling Extension makes sure that a solution from that designated IDE is imported. Otherwise, it will produce an error notice.

Figure 1. Preferences page for Visual Studio IDE selection
2008 checked under

The integration of Rational Modeling Extension for Microsoft .NET with Visual Studio 2008 is inevitable to support the 3.0 .NET framework, which defines several application-programming interfaces for service modeling.

This integration provides a seamless migration of target development platform from the 2005 to the 2008 version of Microsoft Visual Studio. A 2005 solution that is already imported into the Rational Software Architect workspace does not need to be reimported, and you do not need to restart the software after you decide to migrate from Visual Studio 2005 to 2008. However, to ensure that Rational Modeling Extension continues to connect with the upgraded Visual Studio 2008 environment, select the Visual Studio 2008 option for “Which Visual Studio IDE?” in Windows > Preferences > Modeling > .Net Modeling, as previously shown in Figure 1, after migrating the solution to Visual Studio 2008 environment.

Support for Windows Communication Foundation

Microsoft Windows Communication Foundation (WCF) is designed in accordance with service-oriented architecture (SOA) principles to support distributed computing where people use the services. A WCF service is composed of three parts:

  • Service class that implements the service to be provided
  • Host environment to host the service
  • One or more endpoints through which a client can connect to the service

All communications with the WCF service are through the endpoints. The endpoints specify a contract that defines which methods of the service class will be accessible through the endpoint. Each endpoint may expose a different set of methods (see the Microsoft Developers’ Network, MSDN, for more about WCF-based service implementation).

This Rational Modeling Extension supports WCF service modeling and subsequent code generation:

  • Modeling of WCF service components
  • Forward transformation of WCF to C#
  • Reverse transformation of WCF from C#

WCF service modeling and code generation

Rational Modeling Extension for Microsoft .NET provides modeling support for WCF service components, including modeling Service Contracts, Data Contracts, and Message Contracts. With the .NET WCF profile, you represent WCF constructs in a UML model (see Figure 2). The profile has representation options for almost all of the attributes supplied by the WCF framework to design a WCF service library. Each stereotype provides a set of properties for specifying different parameters of a WCF attribute (Figure 3).

Figure 2. WCF stereotypes
Apply Stereotypes view
Figure 3. WCF stereotype properties
Properties view

WCF profile can be applied in conjunction with C# profile for specifying C# specific properties alongside WCF properties. The following sub sections talk about the individual stereotypes for WCF service modeling. If WCF stereotypes have been applied, forward transformation using UML-to-C# will generate code accordingly.

Service Contract

A WCF service can be defined by either a class or by an interface with groups of operations that define the offerings of the service. The Service Contract ties together multiple related operations into a single functional unit. To create a Service Contract, operations are grouped together, either by declaring them within an interface marked with the ServiceContract attribute, or by defining them in a class marked with the same attribute. WCF services define the operations by creating a method and marking it with the OperationContract attribute.

For modeling a Service Contract, you can apply the Service Contract stereotype (Figure 4) on a class or an interface. The contract can define service-level settings, such as the namespace of the service, a corresponding callback contract, and other such settings through Service Contract properties. It also defines a set of operations with the Operation Contract stereotype (Figure 4) applied to them and the Parameters value set. Listing 1 shows the service definition generated in C# from the model in Figure 4.

Figure 4. Modeling a Service Contract
Modeling a Service Contract
Listing 1. Service definition generated in C#
	// @generated
	public interface ICalculator
	    // @generated
	    Int32 add(Int32 param1, Int32 param2);
	    // @generated
	    Int32 subtract(Int32 param1, Int32 param2);

Internal execution behavior of a Service Contract implementation can be specified with the Service Behavior stereotype. Apply the Service Behavior stereotype to a service implementation to specify service-wide execution behavior. To specify execution behavior at the method level, use the Operation Behavior stereotype (Figure 5). Listing 2 shows the code generated from the Service Behavior model.

Figure 5. Service Behavior attribute
Service Behavior attribute
Listing 2. Code generated from the Service Behavior model
	// @generated
	public class Class1
		// @generated
		public void Operation1()
			//TODO: Auto-generated method stub
			throw new System.NotImplementedException();

You can use the Callback Behavior stereotype to configure or extend the execution behavior of a callback contract implementation in a client application. This attribute performs the same function for the callback class as the ServiceBehavior attribute, with the exception of instance behavior and transaction settings.

The Transaction Flow stereotype on an Operation Contract (Figure 6). specifies whether a service operation accepts incoming transactions from a client.

Figure 6. Transaction Flow stereotype
Transaction Flow stereotype

Data Contract stereotype

All Service Contracts have an associated implicit or explicit Data Contract, which defines the data that the service works on. The data types that a service uses must be described in metadata to enable others to interoperate with the service. The descriptions of the data types are known as the Data Contract.

Rational Modeling Extension allows specifying the Data Contract with the help of the Data Contract stereotype. A data contract can have multiple data members, which are specified by applying the Data Member stereotype on a UML property, a C# property, and such (Figure 7). Listing 3 shows the code generated for the Data Contract definition.

Figure 7. Modeling the Data Contract
Modeling the Data Contract
Listing 3. Code generated for the Data Contract definition
	// @generated
	public struct Student
		// @generated
		public Object Name;
		// @generated
		private Int32 telephone;
		// @generated
		private Int32 TelephoneNumber
			get	{return telephone;}
			set	{telephone = value;}

The parameters in the Data Contract must be of types that can be serialized. WCF supports a serialization engine, the XmlSerializer, which can also be used to serialize parameters. To switch to using the XmlSerializer for a particular operation or for the entire service, apply the XmlSerializerFormat stereotype to an operation or a service (Figure 8). Listing 4 shows the code segment that includes this serializer.

Figure 8. XML Serializer attribute
XML Serializer attribute
Listing 4. Code segment that uses the XmlSerializer
	// @generated
	public class Class1
		// @generated
		public void Operation1()
			//TODO: Auto-generated method stub
			throw new System.NotImplementedException();

Message Contract stereotype

A single type can be used to represent the entire message. Although it is possible to use a Data Contract for this purpose, the better way to do this is to use a Message Contract, because it avoids unnecessary levels of wrapping in the resultant XML. Additionally, Message Contracts allow exercising more control over resulting messages. For instance, you can specify which pieces of information should be in the message body and which should be in the message headers.

A Message Contract describes the format of a message. For example, it declares whether message elements should go in headers rather than in the body of the message (source: MSDN Library, cited in Resources).

The Message Contract stereotype can be applied on class for describing a message with Message Header and Message Body Member stereotypes for properties/fields (Figure 9). Listing 5 shows a Message Contract generated.

Figure 9. Modeling the Message Contract stereotype
Modeling the Message Contract stereotype
Listing 5. Code generated for the Message Contract
	// @generated
	public class GetCustomerRequest
		// @generated
		private Int32 _nID;
		// @generated
		public Int32 ID
		  get	{return _nID;}
	        set	{_nID = value;}
		public Student student;

Specifying faults

In all managed applications, Exception objects represent processing errors. In WCF applications, service methods communicate processing error information by using fault messages.

A Fault Contract can be associated with a service operation to denote errors that can be returned to the caller. An operation can have zero or more faults associated with it. In Rational Modeling Extension, the Fault Contract stereotype can be applied on an Operation Contract (Figure 10). Listing 6 shows how the Fault Contract is associated with the Operation Contract.

Figure 10. Capturing faults
Capturing faults
Listing 6. Fault Contract associated with the Operation Contract
	// @generated
	public void Operation1()
		//TODO: Auto-generated method stub
		throw new System.NotImplementedException();

Given that a stereotype can be applied only once on a single element, you can apply the Fault Contract stereotype to an operation only once. However, if you want to add more Fault Contract for an operation, you can type the fault contract description string in the attributes property of the CSharp Method stereotype.

Default values for stereotype properties

The stereotype properties, which are of Boolean, integer, or enumeration types, have been assigned default values in the profile. Table 1 lists the default values for the properties of the CallBack Behavior stereotype. When a stereotype property is set to default value, the transformation does not generate the corresponding named parameter for corresponding WCF attribute. If all the properties are set to default values, transformation generates only the attribute without any parameter. This essentially means that the WCF attribute will utilize the default constructor. Whenever there is a value for the property different from the default, transformation generates the named parameter for that.

Table 1. Default values for Properties


WCF reverse engineering

The objective of reverse engineering is to capture the WCF service library as UML model. Rational Modeling Extension supports round-Trip Engineering (RTE) for WCF service library modeling and code generation. While reverse engineering, C#-to-UML transformation identifies the WCF attribute (if any) applied to C# constructs. If any WCF attribute is encountered, it will apply the “.NET WCF” profile to the temporary UML model created. It then parses the attribute string and extracts all of the properties for the WCF attribute. The WCF stereotype is applied on the corresponding UML element, and all properties of the stereotype are set.

While doing WCF modeling, you might want to apply multiple stereotypes to a single element. For example, an Operation Contract can have multiple Fault Contract stereotypes defined. UML restricts applying a stereotype on an element multiple times. Therefore, if you need to apply Fault Contract multiple times on a UML method, apply the first one on the UML method and put the rest in the attribute section of the CSharp Method stereotype. During reverse transform, the first Fault Contract encountered will be converted to a stereotype and the rest of the Fault Contract attributes will be stored in the attributes property of the CSharp Method stereotype. You can apply Known Type and Service Known Type stereotypes multiple times in the same way.


To keep Rational Modeling Extension for .NET in synchronization with Microsoft Visual Studio 2008, Rational Modeling Extension provides support for integration with Visual Studio 2008. This gives developers the flexibility to work with either 2005 or 2008 versions of Visual Studio editors for modeling and code generation when using Rational Modeling Extension. It also provides the .NET framework 3.0-defined Microsoft Windows Communication Foundation-based service modeling and code generation.



Get products and technologies



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Rational software on developerWorks

ArticleTitle=IBM Rational Modeling Extension with Microsoft Visual Studio 2008 and .NET Framework 3.0 support