Rational® XDE Professional v2002  Release 2.1
.NET™ Edition

 

 

Evaluators Guide

 


 

Table of Contents

 

 

Preface. 3

Welcome to Rational XDE. 4

Integrated Design and Development Environment.. 6

Automatic Creation of UML Models from Code. 14

Web Services.. 20

Customized Patterns.. 27

Best Practices for .NET Development.. 37

Getting More Return From Your Models.. 38

Flexible Team Development and Configuration Management.. 45

Integrated Use-Case Management (IUCM) 46

Conclusion.. 48

Appendix.. 49


Preface

Welcome to the Rational® XDE Professional v2002 Release 2.1 - .NET Edition Evaluators Guide.  This guide was created to help you evaluate Rational XDE Professional v2002 Release 2.1 - .NET Edition (Rational XDE or XDE for short) and outlines the unique values that Rational XDE brings to developers.  Exercises in this guide let you experience the product first-hand.  Each exercise is independent of the previous one and takes about 30 min to complete.  For a better introduction to Rational XDE, we recommend you follow this guide sequentially.

 

This guide is divided into the following sections:

  • Welcome to Rational XDE
    • Overview of Rational XDE and instructions for installing Rational XDE and getting ready to perform the exercises in this guide.  In this section you will create a Visual Studio .NET solution that will hold the projects created in the exercises of this guide.
  • Rational XDE Key Differentiators
    • Description of key benefits provided by Rational XDE to developers:
      • Integrated design and development environment
      • Automatic creation of UML models from code
      • Web services
      • Patterns
      • Best practices for .NET development
      • Getting more return form your models

o        Step by step directions and exercises for you to experience the key benefits.

  • Flexible Team Development and Configuration Management
    • Overview of the integration between the Rational ClearCase family of products and Rational XDE illustrating the ability to distribute the development of models and code across your team based on your needs.
  • Integrated Use-Case Management (IUCM)
    • Overview of the integration between Rational RequisitePro and Rational XDE illustrating the ability to manage software requirements documented in use cases.
  • eXtending your Development Experience
    • Overview of the Rational Developer Network, a unique Web site that provides a wealth of information for software professionals, including Rational XDE and Microsoft Visual Studio .NET information.   If you already are a Rational customer with an active maintenance agreement, you can register to get access to the Rational Developer Network at www.rational.net.

 

We hope this guide is a convenient resource for learning about Rational XDE Professional .NET Edition.

 

 


Welcome to Rational XDE

 

Rational XDE has been designed from the ground-up for developers as an eXtended Development Environment (XDE).  Fully integrated into the Microsoft Visual Studio .NET Integrated Development Environment (IDE), Rational XDE allows developers to design and code within a single environment, avoiding the need to switch between different, non-integrated tools. 

 

If you are familiar with the Microsoft Visual Studio .NET IDE, you will find the Rational XDE user interface very familiar.  If this is your first exposure to the Microsoft IDE you may want to visit the appendix of this guide for an overview of the common windows you will be manipulating in the exercises.

 

Before installing Rational XDE, you must install Microsoft Visual Studio .NET.  If you do not have a copy of Microsoft Visual Studio .NET, you may want to download the trial edition from http://msdn.microsoft.com/vstudio/productinfo/trial.asp or contact Microsoft to purchase your copy.

 

Installing Rational XDE

 

First ensure that your system complies with the system requirements for Rational XDE:

 

Operating System

Windows 2000 Professional SP2 or SP3, or

Windows 2000 Server, or

Windows 2000 Advanced Server, or

Windows XP Professional, or

Windows NT 4.0 Workstation SP6a

Processor

Pentium II-class processor, 450 MHz 

  Recommended: Pentium-III class, 700 MHz

RAM

Minimum:  256 MB; Recommended:  512 MB

Disk Space

Minimum:  400 MB for installation directory; 50 MB for workspace Recommended:  2-4 GB for workspace

Video

Minimum screen resolution: 800 x 600 pixels, 256 colors Recommended: 1024 x 768 pixels, 16-bit color

 

If you do not already own Rational XDE Professional, you can download the evaluation software from our Web site or request a copy of the Rational Software Solution for Microsoft .NET Developers CD. 

·                 To download the evaluation software, go to http://www.rational.com/tryit/xde/dotnet.jsp. Click Download Evaluation Software. Scroll down until you see a  icon

·                 To request the CD, go to http://www.rational.com/tryit/xde/dotnet.jsp#netcd. Click on the  icon

 

To install the Rational XDE evaluation software:

·         From the Web, click on the  icon. 

    • Or from the CD main page, select Try It > Rational XDE Professional.

·         Follow the directions to save the installation software to disk.

·         Extract the content of the ZIP file you saved to a temporary directory.  Double-click on Setup.exe.

·         In the Rational Software Setup wizard, click Next.

·         In the Choose Product screen, select Rational XDE Professional .NET Edition and click Next.

·         Read and accept the agreement.  Click Next.

·         On the Select Configuration screen, provided you do not have other Rational tools installed, you may browse to select a different installation location than the default directory.  Click Next.

·         Click Next until you reach the last pane of the installation wizard.

 

NOTE: The Rational XDE evaluation software is controlled by NetQuartz software and requires an Internet connection. The release version of Rational XDE does not have these dependencies.

 

NOTE2:  If you have installed a product, which relies upon J-Integra by Intrinsyc Software Inc., you may experience a conflict resulting in Rational XDE reporting errors upon startup.  To avoid this, simply edit your system environmental PATH variable and ensure that the entry \Program Files\Rational\common is ahead of any J-Integra entry.  After a system restart, you should be on your way!

 

Getting Started

 

In this section, you will create a Microsoft Visual Studio .NET blank solution that will hold the projects created in the subsequent exercises. 

  1. Select Start > Programs > Microsoft Visual Studio .NET > Microsoft Visual Studio .NET to start Microsoft Visual Studio .NET and Rational XDE.
  2. Select File > New > Blank Solution….
  3. Keep the default selection:  Visual Studio Solutions as project type and Blank Solution as template.

  4. Name the solution Test Drive and accept the default location.  Click OK.

You are now ready to experience the power of Rational XDE!  The Test Drive solution will be your starting point for the upcoming four exercises in this guide.

 


Integrated Design and Development Environment

 

Rational XDE combines design and development into a seamless, tightly integrated experience.  This eXtended Development Environment provides essential developer capabilities that are fully integrated into the Microsoft Visual Studio .NET technology, thereby providing one consistent look and feel and experience. 

 

Modeling is now as much a part of your IDE as your code editor, compiler and debugger.  With this combined environment, your primary development tools follow the same menus, gestures, and usage metaphors, which accelerate your learning curve and promote the use of design, code generation and code synchronization as a daily function. 

 

Ultimately, this leads to developing better software faster!

 

 

Figure 1.  Design and development within one environment Access code and model simultaneously.

 

In this section you will experience the following key Rational XDE features:

·      Creating model from code

·      Automatic or manual code synchronization

While creating a simple C# application, you will see Rational XDE build the visual model for the application and you will use this model to understand how the application fits within the Microsoft Visual Studio .NET Framework.  Along the way, you will also experience the effectiveness of Rational XDE to quickly change properties of multiple elements.  Finally, you will experience the automatic synchronization in action by modifying your model and watching your code update and then by modifying your code and watching your model update.

  1. This exercise assumes that model to code auto synchronization is turned off. If you have experimented with auto synchronization prior to reaching this exercise, please follow these steps first:
    Select Tools > Options.  On the left side, scroll down, click the Rational XDE folder, then the Round-Trip Engineering folder to see the Auto Synchronization options.
  2. With the Test Drive solution open, select File > New > Project….
  3. Select Visual C# Projects as project type and Windows Application as template.
  4. Click the Add to Solution radio button

4.5.       Rename the project DateAndTime and keep the default location.  Click OK.

The DateAndTime project is added to the Test Drive Solution.

DateAndTime project

 

  1. Click on the Toolbox  located the left side.  If the Toolbox is not visible, select View>Toolbox.
  2. Add a Button , and a textbox  to the Form 1.
  3. Double click on button1 to open the source code window for the button.

  4. Complete the button1_Click() method with the following call:

    textBox1.Text = DateTime.Now.ToString();

 

 

Text Box:

 

  1. In the Solution Explorer, right click on the DateAndTime project and select Debug > Start new instance to build and execute the application. 
  2. Verify that your application displays the date and time in TextBox1 when you click button1.

  1. Close the application by closing the Form1 window.

 

Creating UML Models from Code

 

13.   In the Solution Explorer, select the DateAndTime project, and click on the Synchronize icon .

  1. A Rational XDE model is added to the DateAndTime project in the Solution Explorer.

DateAndTime model

 

  1. Click on the Model Explorer tab and notice the DateAndTime model.

  1. Expand the namespace, and the Form1 class, to view the UML representation of the Form class that was created during synchronization.

 

 

Key Benefit
Rational XDE and Microsoft Visual Studio .NET work together using shared technology and a tight integration to create a UML design model of your application with just one click from within the Visual Studio .NET IDE.  You can now visually model your code without ever leaving your favorite development environment, making designing your applications easier than ever.

 

Visualizing the .NET Framework Classes

  1. From the Model Explorer, drag the Form1 class () onto the drawing surface where the  Main diagram should already be opened.

  1. Right click on Form1 in the diagram and select .  This adds to the current diagram additional model elements that are related to the element(s) currently selected in the diagram.
  2. In the Add Related Shapes dialog, set Select in Model(s) to All Models.  Keep the Expands to N Levels to 1.  Click OK. 

Key Benefit
Through a visual model, Rational XDE helps you learn about the .NET Framework and understand how your application uses the .NET Framework components. By expanding your classes, you can quickly see which .NET Framework components your application depends on.  Relationships between your application classes and .NET Framework components help you visualize how your application uses these components.  This information gives you quick access to the system library details you need while building your application.

19.20.   Select Edit > Select All Shapes to select all the shapes in the diagram.

20.21.   In the Properties view  located at the bottom right, scroll down to the View section and enter 4000 for Height and 3000 for Width.  Click away to effect the change on the diagram.

NOTE: Only the properties common to all selected elements are displayed.

Key Benefit
Rational XDE’s tight integration with Microsoft Visual Studio .NET provides a seamless way to modify properties of multiple model elements in one gesture, the same gesture that you use while you develop your software application.

21.22.   Click on the diagram tab  to give the focus to the diagram.

22.23.   Click the  Arrange All Elements icon on the toolbar.

23.24.   Change the Zoom factor to 75%  for better viewing

24.25.   Use the cross hair  in the bottom right corner of the diagram to view all classes with a bird’s eye view.

Cross hair

 

25.26.   Using the Ctrl key, select three of the classes displayed in the Main diagram.

26.27.   Click on the fill color  icon on the main toolbar and select a new color.  The classes background change to that color for easy and quick identification.

Key Benefit
With Rational XDE you can leverage formatting options, like colors, to make your models easier to read and understand.

 

Viewing Code And Model Simultaneously

27.28.   At the top of the drawing area, select the  tab representing the code view for the Form1 class.

  1. Drag the tab down to the middle of the IDE.  You will notice an icon resembling a document as you do this.  Release the mouse and select New Horizontal Tab Group.

Key Benefit
You can customize your work area to see both the visual model and your code at the same time, allowing you to work on either the code or the model and see how your changes impact each area.

  1. With Form1 selected on the diagram, select Format > Auto Resize to better view the text of attributes and operations.
  2. Right click on Form1 in the Main diagram and select Browse Code to view the code for that form in the Visual Studio IDE code editor window.

Key Benefit

Rational XDE conveniently takes you to the location in the code that applies to your selection context.

 

 

 

 

 

Synchronizing Code and Model Automatically

 

  1. Select Tools > Options.  On the left side, scroll down, click the Rational XDE folder, then the Round-Trip Engineering folder to see the Auto Synchronization options. 
  2. Check the Automatic Synchronization checkbox.   Keep the default settings.  Click OK.

Key Benefit
With Rational XDE, you can leave the burden of maintaining code and model in sync to the tool. Turning auto synchronization on will then free you from the hassle of manually synchronizing your code with your model.  Additionally, Rational XDE lets you to decide when synchronization occurs and how conflicts between code and model are handled.   Because auto synchronization
upon each and every change can be distracting, you can turn it off until you are ready to generate code from your model. 

  1. In the Main diagram, right click on the Form1 class, select Add UML > Operation.
  2. Type GetFormNumber.  Click away from the class.  Notice that the Model Explorer automatically displays the new operation.

                       

Key Benefit
Rational XDE provides multiple representations of model elements and maintains them in sync at all times.

  1. With Form1 selected on the diagram, choose Format > Signature > Operation Signature to display the operation signatures on the diagram.
  2. Click on the  Arrange All Elements icon.
  3. Click on the Form1.cs window tab. Because auto synchronization is on, this action automatically updates the Form1 code with the new GetFormNumber() operation.

 

  1. Modify the source code as follows:


 

  1. Click in the Main diagram.  Because auto synchronization is on, this automatically initiates the synchronization between code and model, as indicated by the Synchronize icon  pulsing on the Rational XDE status bar. 
  2. Wait until the pulsing icon disappears. This is your indication that the synchronization is complete. 

    Once code and model are synchronized, you can see the changes you made to the
    Form1 class automatically updated in the model diagram.

Updated attribute signature

 

Updated operation signature

 
                 

Key Benefit
With auto sync turned on, changes in your source code are automatically updated in your model.  Because Rational XDE keeps the visual representation of your application current, you can work the way you feel most comfortable, either in the model or in the source code, without the hassle of having to manually synchronize the two.

  1. In the Solution Explorer, right click the DateAndTime project and select Save DateAndTime.
  2. Close the ,  and  windows.

 

 

Integrated design and development increases developers’ productivity by providing an extended development environment where code and model are kept synchronized at all times.

 

With Rational XDE, developers work the way they feel most productive, either in the model or in the code because Rational XDE handles the hassle of maintaining code and model synchronized.  Developers simply specify how they want conflicts between code and model to be resolved and Rational XDE handles the rest! 

 

Additionally, Rational XDE maximized your efficiency by allowing you to decide when to turn on automated synchronization.  When you want to test a few designs or apply some patterns without committing the model changes to code, you simply turn off the auto synchronization option.  You don’t have to wait for the tool to synchronize code and models. Other times when you don’t want to have to think about your code and model being out of sync, you turn on the auto synchronization option, and at any change, in model or code, will be automatically synchronized.

 

The tight and seamless integration of Rational XDE with Microsoft Visual Studio .NET makes modeling as much a part of the IDE as the code editor and debugger, which accelerates the learning curve and promotes the use of design, code generation, and code synchronization as a daily function.  With Rational XDE developers use the same menus, gestures, and usage metaphors as in the Microsoft’s Visual Studio .NET IDE to effectively work on model elements. 

 


Automatic Creation of UML Models from Code

 

The Unified Modeling Language (UML) is the industry standard notation for software development.  With this common language, communication is better, development time is shorter, complex systems are more easily understood, and designs are cleaner and more maintainable.  However becoming proficient at UML can be time consuming.  To help developers learn UML while they code, Rational XDE automatically generates the UML representation of your code directly from your source files!  The generated models are beneficial for documenting your work, understanding complex projects through visualization and harvesting your work for future reuse. 

 

Figure 2.  Learn UML While You Code – As developers work in their code, XDE instantly reflects any changes in the corresponding UML model.

 

In this exercise you will use one of the examples that ships with Visual Studio .NET to experience the following key Rational XDE features:

·      Code visualization

·      Model references to the .NET Framework

·      Learning UML as you code

 

NOTE:  Because the Visual Studio .NET samples do not typically get installed when installing Visual Studio .NET, you likely will be asked for your Visual Studio CD (or a network location from where you installed Visual Studio .NET) at the start of the exercise.

 

 

  1. If you have not followed this guide sequentially or have experimented with the synchronization options, please enable auto synchronization at this time: Select Tools > Options.  Expand the Rational XDE folder on the left, and select Round-Trip Engineering.  Check the Automatic Synchronization checkbox on the right.  Click OK.
  1. From the Start Page, click on the Find Samples tab . If the Start Page is not visible, select Help > Show Start page.

 

  1. Select Visual C# Developer from the Samples Profile drop down list.

 

  1. Keep the Keyword default value selected for the Filter by field.  Type scribble and click Go.

 

6.5.       Click on the  search result. At this time you may be asked to locate the sample solution file.  You can either load your Visual Studio .NET CD or point to the network location from which you installed

 

7.6.       Click  and accept the default location of MyDocuments.

NOTE:  This exercise has you copy the sample files, rather than load them, to remain within one instance of Visual Studio .NET.  Loading the files would invoke another instance of Visual Studio .NET, and running multiple instances of Visual Studio .NET can become memory intensive.

8.7.       Select File >  Open Solution and navigate to the MyDocuments\samples\VCSharp\General\Scribble directory.

 

  1. Select Scribble.sln and click Open.  If asked to save changes to the Test Drive solution, click Yes.

11.9.       In the Solution Explorer, using the Ctrl key, multi-select the three C# files:  Scribble.cs, ScribbleDoc.cs, and ScribbleView.cs.

Key Benefit

Rational XDE is flexible enough to support model-code synchronization at the class, file, project or solution level.  This allows you to quickly visualize only the code that interests you.

12.10.   Click the Synchronize icon  in the Solution Explorer toolbar. 

13.11.   Wait for the synchronization to complete. Notice the synchronization icon , progress bar and status in the Rational XDE status bar.  During synchronization, Rational XDE automatically created aScribble model in the Model Explorer and opened the model Main diagram (Scribble.mdx::Main).

14.12.   In the Model Explorer, expand the Scribble namespace.  Rational XDE has added four UML classes  (MainWindow, ScribbleDoc, ScribbleView and Stroke) from the Scribble C# code.  It also added  references to the .NET Framework components that are referenced by the Scribble project.

 

 

Visualizing Code with UML

 

15.13.   From the Model Explorer, drag the MainWindow class onto the  diagram.

16.14.   On the diagram, right click on MainWindow and select Add Related Shapes…. 

  1. Verify that the Scribble model is selected in the Select in Models drop down list.  Increase the Expand to N Levels to 2.  Click OK.

 

Key Benefit

When displaying relationships between elements, you can select the specific models to add elements to your diagrams, as well as the direction and type of the relationships between these elements and elements already on your diagrams.  This level of flexibility allows you to visualize your code at the right level of abstraction, quickly and easily. 

 

  1. Increase diagram readability using the Arrange All Elements icon , the Zoom factor , and the cross hair .

 

Understanding References to Visual Studio .NET Framework Classes

 

22.17.   In the Main diagram, right click the ScribbleDoc class and select Add Related Shapes…

  1. From the Select in Models drop down list, select the System.Drawing model.  Set Expand to N levels to 1.  Click OK.

 

25.19.   Click the Arrange All Elements icon.  Notice the System.Drawing Pen class is added to the diagram.

Key Benefit

Rational XDE creates a reference model for each .NET Framework component referenced in your project.  By visualizing the relationships between your classes and the .NET Framework, these reference models make it easy to learn the .NET Framework classes as you develop code.

 

Assisted Modeling

 

Now let’s add a C# property to your ScribbleDoc class so that you can query the class to determine if the associated document is currently the active document.

26.20.   Use the cross hair  to view the ScribbleDoc class on the diagram.

27.21.   Open the Toolbox .  If you do not see a Toolbox, select View > ToolBox.

28.22.   From the Toolbox, click the  category in the Toolbox.

29.23.   Click on  and click ScribbleDoc on the drawing surface. 
The XDE Add C# Property dialog is displayed.

Key Benefit

Rational XDE accelerates your UML learning curve by leveraging what you already know, C#, Visual Basic.NET and ASP.NET.  Drag and drop language specific elements from the Rational XDE C#, Visual Basic or Web Toolbox to create UML models using a vocabulary you already understand.

30.24.   Enter pActive as the Property Name.  Leave the Property Access as public.

31.25.   Select bool from the Property Type drop down list, as the form will either be active or inactive.

Key Benefit

Rational XDE conveniently lists all C# primitive types, saving you time associated with correcting typing errors.  User-defined types may also be typed into the edit box.

32.26.   Check the box Create field to store property value.

33.27.    Enter bStatus as the Field Name.  bStatus will be a private variable.  Click OK. 

NOTE: notice on the diagram the
bStatus variable and pActive property added to the ScribbleDoc class. C# properties are represented in UML as stereotyped attributes (<<property>>); ‘+/-’ indicates the attribute visibility (public/private).

34.28.   Right-click ScribbleDoc and select Synchronize.

35.29.   Wait until the synchronization process completes.

  1. Right-click ScribbleDoc and select Browse Code.  Notice the new pActive property, the bStatus variable and its associated get/set methods.

 

 

Key Benefit

The ‘Add C# Property’ and ‘Add Visual Basic Property’ dialogs provided in Rational XDE supplement the standard Visual Studio .NET dialogs with the ability to create a private field to store the value of the property internally.  In this example, pStatus stores the active state of ScribbleDoc.  This is especially useful when developing Web services where fields may only be accessed via methods. Get and set methods for the new property are also automatically included in the generated code.  

 

Learn UML as you Code

  1. Select the Scribble::Main diagram tab () to make it the active view.
  2. Right-click the ScribbleDoc class and select Select in Model Explorer.
  3. In the Model Explorer, expand the ScribbleDoc class, and select the pActive property. 
  4. In the Properties View, change the Visibility from PUBLIC to PRIVATE.  The change in visibility is reflected in the diagram; pActive as well as its get and set associated operations now display the UML PRIVATE visibility prefix.

NOTE: UML provides 4 options for Visibility:  PUBLIC, PROTECTED, PRIVATE, and PACKAGE.  These options map to language-specific keywords when code is generated from models.

  1. Change OwnerScope from INSTANCE (non-static) to CLASSIFIER (static).  The pActive property is now underlined on the diagram, indicating a static property.

Key Benefit

Rational XDE facilitates learning UML by visually representing UML properties on the diagram itself. 

  1. Select View >Other Windows > Code Properties.  The XDE Code Properties view is displayed over the Properties view. 
  2. Click pActive in the Model Explorer.
  3. Set the Access property to public. Notice the pActive visibility change on the diagram.

    NOTE: C# provides 5 options for Access: private, public, protected, protected internal and internal.
  4. Change Static from True to False.  Notice that pActive is no longer underlined on the diagram.
  5. Select the Properties view.
  6. Locate the OwnerScope property.  Note that its value is now INSTANCE (indicating a non-static variable).

Key Benefit

Rational XDE helps you learn UML as it relates to the tasks you are doing, at your own speed.  In the Code Properties view of Rational XDE you can modify your code using familiar language terms rather than UML. If you are comfortable using UML, you could accomplish these same tasks using the Properties window and modifying the UML-specific properties. In essence, Rational XDE facilitates learning UML by automatically mapping familiar language-specific terminology to UML terminology.   In this exercise, the OwnerScope UML property was kept in sync with the equivalent C# static property.

  1. To gain a quick understanding of how C# maps to UML, select any class on the Main diagram or in the Model Explorer and view its UML properties in the Properties view.  Select the Code Properties view and alter C# values. Note the changes on the Main diagram and in the Properties view.
  2. When you are finished with this exercise, select File > Close Solution to close the Scribble solution.
  3. Close the  window.

    If you want to keep the
    Scribble sample the way it ships with Visual Studio .NET, do not save your changes when asked.

 

Because learning a new notation can be a daunting and time-consuming task, Rational XDE provides language specific assisted modeling (for both C# ad Visual Basic .NET), which allows you to leverage your knowledge of your favorite language to learn the UML.

 

Visualizing your code in UML models helps you quickly understand the relationships and dependencies between your code and the .NET Framework components it uses.  Rational XDE provides flexible options for expanding, arranging and navigating model elements so that you can instantly visualize specific areas of interest.  You can accelerate your learning curve of the .NET framework by using this same functionality to manipulate visual models of the .NET assemblies provided by Rational XDE.

 

The combination of the Code Properties View, the Properties View and code generation help you learn UML as you code, making leaning UML a part of your developer day.

 

With the automatic generation of UML models from code, you become more productive and learn UML as you go, without any downtime.

 

 

 

 


Web Services

 

Rational XDE’s support for Web services allows you to visualize your existing systems, new applications and the interfaces they will each require.

As a member of an IT organization, you are rarely faced with the ease of developing an isolated application.  A more typical scenario is that you are not only concerned with the system you are building, but also with a number of existing systems your organization already has developed, and how the new system will fit into your overall system architecture. 

Using Rational XDE’s support for Web services, you can visualize the overall architecture, understand what interfaces exist today and what new interfaces need to be created.  The interfaces can be with legacy COBOL code, Visual Basic or even a C# application created a few days ago.  They can be written in native code or based on industry standards like Web services. 

Figure 3.  Creating Web services – When developing Web services, Rational XDE creates stereotyped UML classes to represent the Web service elements.

 

In this section you will learn how to do the following with Rational XDE:

·      Model Web services with ASP.NET and Visual Basic.NET

·      Model key client relationships with the Web services

·      Conveniently view WSDL files as UML classes

Today, Web Services are used predominantly to interface with legacy systems developed with varying technologies, such as Visual Basic or COBOL.   Web services provide a standard protocol using SOAP, WSDL and UDDI to interface between the same and different technologies rather than create language specific interfaces.  In this exercise you will create a new web service that retrieves the current time.  You will then update a legacy application, the DateAndTime application, to take advantage of your new web service.

NOTE:
Please ensure you have successfully completed the Integrated Design and Development exercise before beginning this exercise.  Also, i
f you are performing this exercise for the second time, be sure to remove the existing TimeService Web service by deleting the TimeService folder under your /Inetpub/wwwroot/ directory.

  1. If you have not followed this guide sequentially or have experimented with the synchronization options, ensure auto synchronization is disabled: Select Tools > Options.  On the left side, if not l already selected, click the Rational XDE folder, then the Round-Trip Engineering folder to see the Auto Synchronization options.  Ensure that the Automatic Synchronization checkbox is unchecked.  Click OK.
  2. Select File > Open Solution… Browse to your Test Drive solution at /My Documents/Visual Studio Projects/ Test Drive/Test Drive.sln.  Click Open.
  3. Select File > New > Project….

  1. Select Visual Basic Projects as project type and ASP.NET Web Service as template.
  2. Rename the location http://localhost/TimeService. 
  3. Verify that the Add to Solution radio button is checked. Click OK.

After the Create New Web dialog disappears, the Web service is created.

 

Creating a Web Service

7.       In the Solution Explorer, select the TimeService project and click the Synchronize icon .

  1. The Model Explorer is automatically open, and a TimeService model is created.
  2. In the Model Explorer, right click the TimeService model (), and select Add Diagram > Class.  Keep the Diagram1 default name.
  3. Expand the  namespace to view the UML model that was created during synchronization.

  1. Drag the Service1 class  and the Service1 Web service onto the class diagram. Keep the Service1 default name.

Key Benefit

Upon synchronization of your Visual Studio Web service project, Rational XDE creates two UML classes.  The first class represents the XML Web service entry point, the .asmx file, and is easily recognized by the <<NETWebService>> stereotype.  The second class represents the actual implementation of the Web service.  Visual Studio .NET refers to this as the ‘code behind’ file.  Rational XDE conveniently maintains a <<NETWebServiceProxy>> stereotyped relationship between the Web service class and the code behind file.  Using the UML class representations of these Web service files, you can easily model Web service functionality and even begin to create customized Web service patterns.

  1. In the class diagram, right click the Service1 class (the one without the stereotype <<NETWebService>>) and select Add UML > Operation. Name the operation getTime.
  2. In the Model Explorer, expand the Service1 class  and select the getTime() operation.
  3. In the Code Properties view, locate the ReturnType property and click in the value column. 
  4. Click the  button and select System.DateTime. Click OK.

  1. In the Code Properties view, scroll down to the Attributes property.  Type WebMethod.

  1. In the Model Explorer, expand the getTime() operation to see that it has been updated to return the System.DateTime type.
    NOTE: In the Code Properties window, the
    Attributes value is expanded to System.Web.Services.WebMethod.
  2. In the Model Explorer, select the  model and click the Synchronize icon. After the synchronization completes, the Service1 Visual Basic .NET code behind file automatically opens.
    NOTE:  In the Model Explorer, right click the
    Service1 class , and select Browse Code will also open the .asmx.vb code behind file.

  1. In the Model Explorer right click the getTime() operation and select Browse Code.
  2. Add the following code to the getTime() operation:



  1. In the Solution Explorer, right click the TimeService project and select Save TimeService.

 

Congratulations! You have just created a Web service. Next you will test this new Web service.

 

Testing a Web Service

 

  1. In the Solution Explorer, right click on the TimeService project and select Debug >Start new instance. Visual Studio .NET automatically creates a test harness to test your Web service.
  2. In the browser window that comes up, click .




  1. Current date and time

     
    Text Box:

    Click the Invoke button.  The following display (with the current date and time) indicates your Web service has been successfully created. Congratulations!

 

 

 


25.   Close both browser windows that were opened by this exercise.

 

Leveraging Web services in Your Legacy Applications

 

Previously you created a C# application, DateAndTime, to get the current date and time.  You will now update this existing application to obtain the current date and time using your new Web service. 

 

26.   In the Solution Explorer, right click on the DateAndTime project and select Add Web Reference…

Key Benefit

Reviewing a WSDL XML document to determine Web service functionality can be a tedious task. Rational XDE conveniently displays the WSDL XML document as a UML class so that you can quickly identify and understand functionality available from the Web service.  When you add a Web reference in Visual Studio .NET, Rational XDE creates two new UML classes.  The first class represents the WSDL document.  The second class represents the proxy class generated by Visual Studio .NET.  Using the UML representation of the proxy class you can model client interactions with the Web service as if it were a locally available component

27.   In the Address field, enter http://localhost/TimeService/Service1.asmx and hit Enter.

28.   Click the Add Reference button.

NOTE: In the Solution Explorer, notice that the
DateAndTime project now includes a Web reference to the TimeService Web service.

29.   In the Solution Explorer, select the DateAndTime project and click the Synchronize icon. 

30.   In the Model Explorer, notice the update to the DateAndTime model.

31.   In the Model Explorer, right click the DateAndTime model file () and select Add Diagram > Class.  Name the diagram TimeService.

32.   Expand the  namespace and drag the Form1 class () onto the diagram.

33.   Expand the  namespace and drag the Service1 class () onto the diagram.

34.   From the Toolbox, select the  Directed Association and drag from Form1 to Service1.

35.   While the association is still highlighted, go the Code Properties view and set the following values:

Name

mTimeService

XDE will generate a new member variable in Form1, mTimeService of type Service1.

Initial Value

new DateAndTime.localhost.Service1()

XDE allows you to set the initial value of the variable.  In this case you will use a fully qualified name to assign mTimeService to a new instance of the Service1 class, which implements your TimeService Web service.

36.   In the Model Explorer, select the DateAndTime model and click the Synchronize button.

37.   Right click Form1 and select Browse Code.   Notice the new member, mTimeService and its initial value is exactly what you specified in step 35.

38.   In the Model Explorer, right click Form1 button1_Click() operation and select Browse Code.

39.  
Text Box: private void button1_Click(object sender, System.EventArgs e)
{
	textBox1.Text = mTimeService.getTime().ToString();
}

Replace the function body to invoke the Web service call instead:

40.   In the Solution Explorer, right click the DateAndTime project and select Debug->Start new instance.

NOTE: If you run into a namespace compile error, verify in step 35 above that your mTimeService member variable is initialized as follows:

localhost.Service1 mTimeService = new DateAndTime.localhost.Service1();

41.   Click on the DateAndTime application button to see your Web service in action. Close the application.

42.   Close the windows associated with the DateAndTime project.

Congratulations!  You just integrated a Web service into your existing application using Rational XDE.

 

Rational XDE helps speed your learning and adoption of Web services, by reverse engineering a WSDL XML document into a UML class to quickly identify and understand Web service functionality.  When creating Web services in Visual Studio .NET, Rational XDE creates UML classes to represent the .asmx file as well as the ‘code behind’ implementation file and maintains a stereotyped relationship between them.  Using these UML classes, you can model Web services as you would any other component of your application. 

 

You can even take advantage of customized patterns that incorporate your Web service.  Patterns are the focus of the next exercise.

 

Integrating with legacy applications, learning new technologies such as Visual Basic .NET and adopting industry standards such as UML and Web services are just some of the challenges you face daily.  Rational XDE facilitates each of these tasks so that your models can truly represent your system and all of its components, helping you meet the biggest challenge IT organizations face today: integrating disparate legacy systems.


Customized Patterns

 

Patterns are valuable reusable assets that jumpstart the development effort and leverage expertise so that you can finally experience reuse from previous project investments.  Reusing development assets is also critical in jumpstarting any software development effort and ensuring quality designs.  

 

Included in Rational XDE are well-known industry patterns, like the Gang of Four (see “Design Patterns: Elements of Reusable Object-Oriented Software”, Erich Gamma et al.).  Additional patterns are available for download from the Rational Developer Network. But the true power of Rational XDE is in allowing you to visualize and leverage your own patterns.

 

In Rational XDE, patterns can be visually developed using the UML and a built-in pattern engine. Additionally, a user-friendly pattern wizard makes applying patterns easier than ever.

 

Patterns can also be extended by binding code templates, which eliminates the hassle of rewriting the same code over and over.  This binding allows you to supplement patterns with code that is generated anytime you apply the pattern.  This mechanism jumpstarts your coding efforts and improves the quality of your software by reusing proven code contained in code templates.