242
Education Lesson 3 Model-driven integration based on executable UML ® E2E Bridge Base Version 5.1 Release 5.1.4 October 26, 2012 E2E Technologies Ltd Lautengartenstrasse 12 CH-4052 Basel, Schweiz T +41 61 270 97 10 E [email protected] W www.e2ebridge.com

E2E Bridge Education Lesson 3

Embed Size (px)

DESCRIPTION

The E2E Education Lessons 1 -3 serve as a self learning program for developing a Web service with E2E Bridge. The education leads you through a development process divided into three lessons, which will teach you to build services based on the E2E Bridge platform. Each lesson can be accomplished in about a day.

Citation preview

Page 1: E2E Bridge Education Lesson 3

Education

Lesson 3

Model-driven

integration based

on executable UML®

E2E Bridge™

Base Version 5.1

Release 5.1.4

October 26, 2012

E2E Technologies Ltd Lautengartenstrasse 12

CH-4052 Basel, Schweiz

T +41 61 270 97 10

E [email protected]

W www.e2ebridge.com

Page 2: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 2

Table of Contents

1 Errata ................................................................................................................................................................................... 4

2 Introduction ......................................................................................................................................................................... 5

2.1 Documentation Map ..................................................................................................................................................................................................... 6

2.2 Goal of E2E Bridge® Education .............................................................................................................................................................................. 6

3 Extending the Web Service ................................................................................................................................................. 8

3.1 Assignment ....................................................................................................................................................................................................................... 9

3.2 Preparation for Lesson 3 ........................................................................................................................................................................................ 10

4 First Iteration ..................................................................................................................................................................... 12

4.1 Use Case Diagram ...................................................................................................................................................................................................... 13

4.2 Class Diagram ............................................................................................................................................................................................................... 19

4.2.1 Defining Classes ............................................................................................................................................................................................... 21

4.3 Port Type.......................................................................................................................................................................................................................... 40

4.3.1 Defining the Port Type .................................................................................................................................................................................. 40

4.3.2 Defining the Operation .................................................................................................................................................................................. 41

4.3.3 Defining the Operation Parameters ..................................................................................................................................................... 43

4.3.4 Assigning a new Activity Diagram to the Operation ................................................................................................................... 45

4.3.5 Assigning Activity Diagrams to Use Cases ...................................................................................................................................... 48

4.4 Activity Diagram ........................................................................................................................................................................................................... 51

4.4.1 Outlining the Activity....................................................................................................................................................................................... 51

4.4.2 Reading the XML File .................................................................................................................................................................................... 55

4.4.3 Filtering the File Content ............................................................................................................................................................................ 72

4.5 Component and Deployment Diagrams ........................................................................................................................................................ 92

4.5.1 Reworking and Extending the Component Diagram .................................................................................................................. 93

4.5.2 Extending the Deployment Diagram .................................................................................................................................................. 102

4.6 Compilation .................................................................................................................................................................................................................. 107

4.7 Solving Errors ............................................................................................................................................................................................................ 108

4.8 Testing with E2E SOAP Test Tool ..................................................................................................................................................................... 110

4.8.1 Testing the File Reading ............................................................................................................................................................................. 110

4.8.2 Testing the Filtering ...................................................................................................................................................................................... 112

5 Second Iteration .............................................................................................................................................................. 115

5.1 Class Diagram ............................................................................................................................................................................................................. 116

5.2 Activity Diagram ........................................................................................................................................................................................................ 124

5.2.1 Outlining the Activity.................................................................................................................................................................................... 124

5.2.2 The Currency Calculator ............................................................................................................................................................................ 129

Page 3: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 3

5.2.3 Using the SOAP Adapter ........................................................................................................................................................................... 138

5.2.4 Implementing the Currency Conversion .......................................................................................................................................... 165

5.2.5 Implementing Additional Calculations ............................................................................................................................................. 200

5.2.6 Finalizing the Activity Diagram Query Products ........................................................................................................................ 207

5.3 Component and Deployment Diagrams ....................................................................................................................................................... 211

5.3.1 Reworking and Extending the Component Diagram ................................................................................................................ 212

5.3.2 Extending the Deployment Diagram .................................................................................................................................................. 218

5.4 Compilation ................................................................................................................................................................................................................. 222

5.5 Solving Errors ........................................................................................................................................................................................................... 223

5.6 Testing with E2E SOAP Test Tool ................................................................................................................................................................... 225

5.6.1 Requesting the Web Service with the Excel Client ................................................................................................................... 228

6 Testing with E2E Analyzer .............................................................................................................................................. 232

6.1 Starting the Service and the Analyzer ........................................................................................................................................................ 233

6.2 Test Case Properties ............................................................................................................................................................................................. 235

6.3 Tracing through the Service ...............................................................................................................................................................................237

Page 4: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 4

1 Errata

This version of Lesson 3 may contain screenshots which are not up to date, as some images are still related to MagicDraw

16.6.

Page 5: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 5

2 Introduction

Page 6: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 6

2.1 Documentation Map

The Bridge is delivered with comprehensive documentation. Apart from this self-study, the Bridge also comes with many

examples you can have a look at. Each feature is subject of an example that is ready to run.

This chapter provides an overview about all documentation available after installation. If you did not change the default

location of the E2E documentation, you will find all documents and examples in folder C:\E2EBridgeDocumentation_5

\Documentation.

Additionally, all documentation is available online at the E2E Homepage.

Document Content

E2E Bridge Education Lesson 1-3

(this document)

Comprehensive self-learning guide, which leads you through all steps of

creating a Web Service. Additionally, it provides conceptional information for

each topic.

E2E Bridge Reference Guide Comprehensive Bridge guide containing information about architecture,

concepts, modeling, E2E Action language, add-ons, and import/export

mechanisms.

E2E Bridge Server User Guide Comprehensive guide explaining concepts and usage of E2E Console, which

comprises all management tasks to run the Bridge and deployed composite

services.

E2E Bridge Builder User Guide Comprehensive guide explaining concepts and usage of E2E Builder including

all tools like E2E Model Compiler, E2E Model Debugger, and E2E Importers.

E2E Bridge Server Installation Guide Description of the installation of E2E Console including a troubleshooting

chapter. This guide also contains a description of the following firmware

installations:

E2E SQL Libraries to integrate SQL databases

E2E SAP Libraries to integrate SAP systems

E2E Java Libraries to use Java classes in your service

E2E Bridge Builder Installation Guide Description of the installation of E2E Builder including a troubleshooting

chapter.

E2E Analyzer Installation Guide Description of the installation of E2E Analyzer.

Page 7: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 7

2.2 Goal of E2E Bridge® Education

This document is one of three documents, which serves as a self learning program for developing a Web Service with E2E

Bridge®. The education leads you through a development process divided into three lessons, which will teach you to build

Services based on the E2E Bridge platform.

Welcome to lesson 3 of the E2E Education. By reading this document, you will learn

in the first iteration how to draw more complex class diagrams

how to reuse activity diagrams

how to copy activity diagrams

how to use decisions

how to design a SOAP interface from scratch

how to work with arrays

how to use value pins

how to define iterations with an expansion region

how to use transformations

how to use static operations within Action Script

how to manage test cases

in the second iteration how to read a file

how to use a backend adapter

how to use an alias

how to map XML data to objects

how to exchange messages with an external SOAP Service

how to use the E2E Action Wizard

The goal of this lesson is to model a Web Service that receives a search request from an Excel client. The requested items

are searched in an XML data source file. For each found record a currency conversion is performed. The necessary

exchange rate is received from an external SOAP Service. If the search is successful, the Web Service sends the search

result back to the client.

Page 8: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 8

3 Extending the Web Service

In lesson 2, the example of lesson 1 was extended. In lesson 3, you will reuse and extend the example of lesson 2 and the

Excel client again. The Web Service will be capable of searching products in a file.

In lesson 1 and 2, the development process was discussed. Below, you find the components and steps of a logical design

process:

1. Use case (roles and their activities)

2. Class diagram (static data structure)

3. Port type definition for modeling a Web Service (Web Service interface, operations)

4. Activity diagram (choreography, system behavior, backend adapters)

5. Sequence diagram (system behavior)

6. Component and deployment diagrams (supported by the by the E2E Components and Deployment Wizard)

7. Compilation of UML models with the E2E Model Compiler

8. Deployment of E2E Composite services to an E2E Server

9. Testing of deployed Service with the E2E Model Debugger

You will also follow these design steps during lesson 3. This time, as it is an iterative process, you will go through this

development process more than once.

Page 9: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 9

3.1 Assignment

In this lesson, you will extend the Web Service of lesson 2. It will read data from an XML file, implement a search

mechanism, get some additional information from an external web service, and manipulate data before sending it to the

Excel client.

The development process will be iterated through two times. In the first iteration, you will use the file system adapter to

read product data from the XML file, a filtering mechanism will be implemented, and you will learn how to work with

arrays.

In the second iteration, you will use the SOAP adapter to call a SOAP operation. The exchange rate conversion example will

be reused, and you will learn how to work with further E2E Action Language operations, actions with special behavior, and

iterations.

The example will be ready to be compiled and deployed after each iteration of the development process. At that points, you

will be able to test the Web Service with theE2E Model Debugger and see first results.

Page 10: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 10

3.2 Preparation for Lesson 3

Open the E2E Builder project Education, and open the UML® model file lesson2 if it has not been opened directly. Save the

file as lesson3.

Select the diagram tab Product Query Overview to display the use case diagram in the diagram pane. Then, right-click the

tab and select Close All Diagrams But Current. This will close all open diagrams except the use case diagram Product

Query Overview.

Page 11: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 11

An XML file was copied to the documentation folder of lesson 3 while installing the education files.

Make sure, that you can find the file catalog.xml (default location C:\E2EBridgeDocumentation_5\Documentation\ pdf\E2E

Education\Lesson3).

Keep the file path in mind, where you actually installed the file, as you will need it in the UML model when defining the file

backend in the deployment diagram.

Page 12: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 12

4 First Iteration

In the first iteration, start with reworking the use case diagram.

Page 13: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 13

4.1 Use Case Diagram

The use case diagram Product Query Overview is displayed.

Change the name of the second use case from Insert Product Data into List to Query Products, because now you are going

to design a query of an XML file containing product records.

Page 14: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 14

Select the use case Insert Product Data into

List.

Click the name of the use case and start typing

the new name Query Products. To finish, press

Ctrl - Enter .

Page 15: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 15

Create a new package Query Products Service

in the package Data / Overview / Use Cases.

Create a new use case diagram in the new

package.

Page 16: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 16

Assign the name Query Products to the use case

diagram.

Reuse the actor Consumer in the package Data / Overview / Use Cases and drag and drop it onto the new use case

diagram Query Products.

Complete the use case diagram by selecting the appropriate icons from the middle bar.

Create the main use case Query Products first and draw an association between this use case and the actor Consumer.

Page 17: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 17

Include the other use cases in the main use case:

Enter Search Keywords

View Search Result

Switch to the diagram tab Product Query Overview. Expand the package Query Products and define a hyperlink on use case

Query Products. Link the created use case diagram by dragging and dropping the use case diagram Query Products as

shown in the picture below.

Page 18: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 18

Now, delete the package Insert Product Data Service as it is not used anymore.

Save the UML model.

Page 19: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 19

4.2 Class Diagram

In the following chapter, the XML data source is analyzed to infer the required data structures of the Web Service.

Below, the XML File containing product data is displayed. The Web Service will read from this data source and send the

filtered data to the Excel client.

<?xml version="1.0" encoding="UTF-8"?>

<catalog>

<product>

<title>Pirates of the Caribbean - The Curse of the Black Pearl</title>

<category>DVD</category>

<manufacturer>Buena Vista Home Video</manufacturer>

<priceUSD>17.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-

/B00005JM5E/qid=1075478699//ref=pd_ka_1/104-2088971-

5001520?v=glance&amp;s=dvd&amp;n=507846</link>

</product>

<product>

<title>Finding Nemo</title>

<category>DVD</category>

<manufacturer>Walt Disney Home Video</manufacturer>

<priceUSD>17.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-

/B00005JM02/qid=1075478699//ref=pd_ka_2/104-2088971-

5001520?v=glance&amp;s=dvd&amp;n=507846</link>

</product>

<product>

<title>Once Upon a Time in Mexico (2003)</title>

<category>DVD</category>

<manufacturer>Columbia Tristar Hom</manufacturer>

<priceUSD>20.27</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B0000WN140/qid=1076055328/sr=1-

2/ref=sr_1_2/102-9079676-4243362?v=glance&amp;s=dvd</link>

</product>

<product>

<title>The Lord of the Rings - The Two Towers (Platinum Series Special Extended

Edition) (2002)</title>

<category>DVD</category>

<manufacturer>New Line Home Video</manufacturer>

<priceUSD>25.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B00009TB5G/ref=pd_ts_d_8/102-

9079676-4243362?v=glance&amp;s=dvd&amp;n=404276</link>

</product>

<product>

<title>Lost In Translation (Widescreen Edition) (2003)</title>

<category>DVD</category>

<manufacturer>Universal Studios</manufacturer>

<priceUSD>18.89</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

Page 20: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 20

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B00005JMJ4/ref=pd_ts_d_2/102-

9079676-4243362?v=glance&amp;s=dvd&amp;n=404276</link>

</product>

<product>

<title>Panasonic SC-HT700 5-Disc Progressive-Scan DVD Home Theater System</title>

<category>Audio &amp; Video</category>

<manufacturer>Panasonic</manufacturer>

<priceUSD>264.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B00008XL1I/qid=1079949505/br=1-

1/ref=br_lf_etk_ce_av__1//104-1167198-

1926310?v=glance&amp;s=electronics&amp;n=172593</link>

</product>

<product>

<title>Zenith XBS344 Progressive Scan DVD-VCR Home Theater System (Silver)</title>

<category>Audio &amp; Video</category>

<manufacturer>Zenith</manufacturer>

<priceUSD>249.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B0000A2UAT/qid=1079949505/br=1-

13/ref=br_lf_etk_ce_av__13//104-1167198-

1926310?v=glance&amp;s=electronics&amp;n=172593</link>

</product>

<product>

<title>Sony DVD/VHS Home Theater System (HT-V1000DP)</title>

<category>Audio &amp; Video</category>

<manufacturer>Sony</manufacturer>

<priceUSD>499.87</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-/B0000CBCO6/qid=1079950507/br=1-

5/ref=br_lf_etk_ce_av__5//104-1167198-

1926310?v=glance&amp;s=electronics&amp;n=172593</link>

</product>

</catalog>

Later, you will model a data structure that stores the data of this file.

<?xml version="1.0" encoding="UTF-8"?>

<catalog>

<product>

<title>Pirates of the Caribbean - The Curse of the Black

Pearl</title>

<category>DVD</category>

<manufacturer>Buena Vista Home Video</manufacturer>

<priceUSD>17.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos/tg/detail/-

/B00005JM5E/qid=1075478699//ref=pd_ka_1/104-2088971-

5001520?v=glance&amp;s=dvd&amp;n=507846</link>

</product>

[...]

</catalog>

The XML file is well structured. The

first line of the XML file is the

header, which states what XML

version and what character set are

used. The element catalog contains

some product elements. Each

product element is containing seven

further elements that store product

data.

Page 21: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 21

Note: In this example, the XML structure is built up from XML elements without using attributes. It would also be

possible to use attributes within the elements as shown in the example below.

<product title=”Pirates of the Caribbean - The Curse of the Black Pearl” category=”DVD”

manufacturer=”Buena Vista Home Video” priceUSD=“17.99” seller=“amazon.com”

sellerType=”web” link=“http://www.amazon.com/exec/obidos/tg/detail/-

/B00005JM5E/qid=1075478699//ref=pd_ka_1/104-2088971-

5001520?v=glance&amp;s=dvd&amp;n=507846“/>

4.2.1 Defining Classes

In this chapter, you are going to model the class diagram. The class diagram contains classes that represent the input and

output structure of the service.

4.2.1.1 Output

You are going to start with the output classes according to the structure of the XML file.

First, create a new Service structure for the extended Web Service.

Create a new package in the package Data /

Services by choosing Package

<<Respository>> from the context menu.

Assign the name QueryProductsService.

To the newly created package

QueryProductsService, the stereotype

<<Repository>> has been applied automatically.

Page 22: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 22

In package Query- ProductsService, create the

new packages Classes and Ports with

stereotype <<Repository>> using the same

menu option.

Create a new class in the package Data /

Services / QueryProductsService / Classes that,

as a query result, will store a list of products.

To find an appropriate name, look at the file

structure of the XML file that was introduced at

the beginning of this chapter. The first element

in the file after the header is called catalog. You

find the opening tag of catalog at the beginning

of the XML structure, and the closing tag at the

end of it.

Choose the same name for the class and, as

class names should begin with a capital letter,

type Catalog. An instance of this class will serve

as output object in order to pass the query

result from the Web Service to the client.

Page 23: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 23

Next, you will create a new class diagram in the

package Classes to visualize the data

structures.

Assign the name Product Query Classes.

Drag and drop the class Catalog onto the class diagram in the diagram pane.

Page 24: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 24

Now, create a class to store the data of a single product. Select a Class icon from the diagram toolbar and place it on the

diagram pane. Double-click the class symbol to open the class specification dialog.

<product>

<title>Pirates of the Caribbean - The Curse

of the Black Pearl</title>

<category>DVD</category>

<manufacturer>Buena Vista Home

Video</manufacturer>

<priceUSD>17.99</priceUSD>

<seller>amazon.com</seller>

<type>web</type>

<link>http://www.amazon.com/exec/obidos

/tg/detail//B00005JM5E/qid=1075478699/-

/ref=pd_ka_1/104-2088971

-5001520?v=glance&amp;s=dvd&amp;

n=507846</link>

</product>

To find an appropriate name, look at the file

structure of the XML file again. The element in

the file that represents a single product, and is

repeated eight times, is called product. You

find the opening tag of product at the

beginning of each XML structure, and the

closing tag at the end of it.

Choose the same name for the class.

Page 25: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 25

Page 26: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 26

In order to map the XML structure to the data

structure in the class diagram later on, you

need to associate the class Product to the class

Catalog.

Note: XML data is mapped to UML classes

using an E2E Action Lan- guage operation.

As a rule, XML elements are mapped to

association ends in a class diagram.

An association is a relationship between

instances of two classes. At least one of the

association ends must have a name. They play

a similar role as attribute names. Actually, all

associations having an association end name

can be represented as an attribute as well.

Click the class Catalog and select the

Association icon from the smart

manipulation toolbar.

Draw the association from the class Catalog to

the class Product.

As in the XML file there are stored several products, all Product elements have to be stored in an array. The array can be

defined by configuring the association between the classes Product and Catalog.

An association can be named, and the ends of an association (also called roles) can be adorned with role names, ownership

indicators, multiplicity, visibility, and other properties.

Page 27: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 27

Double-click the association to open the

Association specification dialog.

Enter contains as name of the association, as a

Catalog contains Products. This increases

readability. The small arrow floating next to

the association line indicates the reading

direction.

Enter the name products in the section Role of

Product (which represents the association end

belonging to class Catalog).

The roles (or association ends) are regarded as attributes of the corresponding class. Assigning them names, they can be

accessed within E2E Action Script (as you will see later on).

In the next step, you will define products as an array containing zero to infinite Products.

Page 28: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 28

By choosing 0..* in the multiplicity field, you

define that the new attribute products is an

array. This array can have zero to infinite

elements of type Product as a Catalog contains

zero to infinite Products..

The array products must be defined as public.

Public attributes can be read and modified in

activities outside the class context.

Page 29: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 29

In the section Role of Catalog (which belongs to

class Product) specify multiplicity 1 as exactly

one instance of Catalog can have an array

containing 0..* Products.

In the association properties tree on the left,

expand the node Roles and select role products.

As mentioned before, you will map the XML structure to the class structure, after reading the XML file containing the

product catalog.

For a better readability of the model, you named the association end products, instead of product in singular. But actually,

the name of the corresponding association end has to match the XML element's name to perform the mapping. On account

of this, you have to specify the external name of products.

This is done by assigning the stereotype <<E2EAttribute>> to the association end products.

Page 30: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 30

Click into the field Applied Stereotype, and then

on the small edit button to open a list of

suggested stereotypes.

Filter the list by entering e2e into the text field

and select the stereotype <<E2EAttribute>>.

Click Apply to assign the stereotype.

Page 31: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 31

Assigning the stereotype <<E2EAttribute>>

leaded to the properties list being appended by

several additional properties. They are tagged

values belonging to the stereotype.

If necessary, scroll down to the end of the

properties list to see the additional properties.

Specify the external name of products as

product, the corresponding name from the XML

file.

Click Close .

Now, the class diagram should look as shown below.

One Catalog contains zero to infinite products. The external name of products is product. Association end products

constitutes an attribute of class Catalog. It is an array that contains elements of type Product.

Page 32: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 32

Comparing the association to the XML structure, you will notice the analogy when saying that instances of class Catalog

contain Products. The data of all product XML elements will be mapped to the association end products (products is an

array attribute of class Catalog).

Class attributes and association ends are different notations for the

same issue. You could drag and drop the association end products to

class catalog to change the notation.

In the next steps, you will map each XML element that is included in an XML element product to new attributes of the class

Product. For instance, the XML element manufacturer will be mapped to attribute manufacturer of class Product.

Page 33: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 33

Double-click class Product to open the

Specification Dialog and apply the stereotype

<<XML>>.

Switch to the Attributes section and add the

attributes listed in the table below using Create >

Property <<XMLElement >>.

Attribute Name Attribute Type Visibility Stereotype

title String public <<XMLElement>>

category String public <<XMLElement>>

manufacturer String public <<XMLElement>>

priceUSD Float public <<XMLElement>>

seller String public <<XMLElement>>

sellerType String public <<XMLElement>>

Page 34: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 34

link String public <<XMLElement>>

You use stereotypes like <<XMLElement>> to control how XML data is mapped to UML classes. For instance, using this

stereotype for class attribute manufacturer, the attribute does not need to be defined on an association end. You will find

more detailed information about data mapping between XML documents and UML classes in chapter XML / UML Class

Mapping of the E2E Bridge® Reference Guide.

Right-click class Product and select Symbol(s)

Properties from the context menu.

Page 35: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 35

In the search field start typing show a to filter the

list.

Set the parameter Show Attributes Stereotype to

true.

Click OK.

Now, your class diagram should look like the one below.

Page 36: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 36

Note: In more complex examples that require to map complex XML data to UML classes and vice versa, you would

import an XML schema into the model. The E2E XSD Importer creates a UML model with all classes having all

required stereotypes and associations.

You modeled the output data according to the structure of the XML file by creating the classes Catalog and Product. The

XML elements of each product record were modeled as stereotyped attributes of class Product.

Save the UML model.

Page 37: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 37

4.2.1.2 Input

Now, define the structure of the input data.

Create a new class in the packageData /

Services / QueryProductsService / Classes that

will contain the title and the search keywords.

Assign the name SearchParameters.

Double-click the class to open the class

specification dialog and change to the tab

Attributes.

Now, define the attributes of the new class

according to the input data that is entered in the

search mask of the Excel client.

Add all attributes listed in the table below.

Attribute Name Attribute Type Multiplicity Visibility

title String public

keywords String 0..* public

Page 38: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 38

After all attributes have been defined, click

Close .

Drag and drop the class SearchParameters onto the class diagram Product Query Classes.

Page 39: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 39

Save the UML model.

Page 40: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 40

4.3 Port Type

In the next development step, you will define the SOAP interface of the Web Service.

4.3.1 Defining the Port Type

In the containment tree, collapse all open packages within the package Data / Services. Navigate to the package Data /

Services / QueryProductsService / Ports, and create a new SOAP Port Type class. This can be done manually (as explained

in lesson 2) or via New Element > Service > SOAP Port Type.

Page 41: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 41

Assign the name QueryProductsPortType.

Double-click the port type and enter a description

of the port type in the Documentation/Hyperlinks

section:

The port type provides an operation to query an

XML file containing product data. The search

result is displayed in the client application.

4.3.2 Defining the Operation

Create an operation for the new port type.

Page 42: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 42

Assign the name queryProducts.

According the SOAP standard, operations of port

types need to be defined as static. In the object-

oriented world this means that no instance of the

port type class is needed to call the operation.

The operation can be called directly without

instantiating the port type class.

Double-click the new operation to open the

operation specification dialog. Select the

checkbox Is Static to set this option to true.

Change to the Documentation/Hyperlinks section

and enter a description of the operation:

The operation defines an interface to query an

XML file containing product data. An object

containing the search parameters is passed in.

An object containing the search result is

returned.

Page 43: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 43

4.3.3 Defining the Operation Parameters

Select the operation queryProducts in the

containment tree and create a new parameter.

Assign the name userInput.

Page 44: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 44

Double-click the new parameter and choose the

type SearchParameters. Leave the Direction as in

and close the dialog.

Create a second parameter and assign the name

productList.

In the first iteration, the output of the operation

will be just a list of products. All additional

calculations will be done in the second iteration.

This has the effect, that in the second iteration

you will have to change the operations interface.

Page 45: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 45

Double-click the new parameter and choose the

type Catalog. Set the Direction to out and close

the dialog.

4.3.4 Assigning a new Activity Diagram to the Operation

At this point, the interface of the Web Service is nearly complete. Each operation must be assigned to an activity diagram of

the UML model.

Operations of a port type represent the interfaces of a Web Service. Activity diagrams implement the behavior of these

operations. Each port type operation has to be assigned to the implementing activity diagram. When the operation is called,

the assigned activity diagram will be executed.

The activity diagram has not been created yet. In the next step, you will directly assign a new activity diagram to the

operation queryProducts.

Select the operation queryProducts in the

containment tree with the right mouse button,

choose Behavior Diagram > Assign….

Page 46: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 46

The Assign Behavior Diagram dialog displays a

list of existing activity diagrams that could be

assigned to the operation. As the operation gets

assigned a new activity diagram click New and

choose Activity Diagram from the drop down list.

The new activity diagram now is listed in the

Assign Behavior Diagram dialog and is assigned

to the operation queryProducts.

Click Close .

Page 47: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 47

The name of the activity respectively the activity

diagram should always correspond to the name

of the operation it is specifying.

Rename the activity to Query Products.

Expand the activity QueryProducts.

The activity diagram Query Products is part of the

new activity that has been created at the same

time.

Note, that the necessary parameter nodes have

been created automatically as well.

Note: If you double-click the operation queryProducts in the containment tree, the assigned activity diagram Query

Products will always open in the diagram pane.

The definition of the third SOAP interface of the Web Service is complete.

Page 48: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 48

Save the UML model.

4.3.5 Assigning Activity Diagrams to Use Cases

For documentation purposes and to simplify navigation through the UML model, you can link use cases to activity

diagrams.

In MagicDraw, switch to the use case diagram tab Query Products you defined earlier.

Page 49: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 49

Select the activity diagram Query Products in

the containment tree.

Drag the activity diagram symbol on the diagram pane and drop it onto the use case Query Products.

Page 50: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 50

The use case Query Products has been linked to the activity diagram Query Products now. In the lower left of the use case,

the activity diagram icon is shown.

Double-click the use case Query Products to open the linked activity diagram.

Save the UML model.

Page 51: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 51

4.4 Activity Diagram

The next step in the development process is to model the implementation of the operation queryProducts.

4.4.1 Outlining the Activity

The first step when modeling complex activity diagrams is to define a rough sketch of the activities.

In the picture below, the completed activity diagram provides an overview of all required UML elements.

The first action calls the activity Read XML File and contains actions to read the XML file and to create the output object

allProducts, which is of type Catalog. The object contains the data title, category, manufacturer, seller, sellerType, and

priceUSD for each product record. To retrieve the data from the XML file you need to use the file system adapter.

Page 52: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 52

The second action calls the activity Filter File Content, which has two input objects: the object userInput of type

SearchParameters containing the array keywords, and the object allProducts, which is the output of the first action Read

XML File. The output of the activity Filter File Content is a subset of records that have been read from the XML file. The

filtered data is assigned to the output object filteredProducts. The object filteredProducts is of type Catalog.

The third action calls the activity Calculate Total and Currencies. For each product record found in the input object

filteredProducts the attribute PriceCHF and some other data, such as total and delivery charge, is calculated and written to

the final object searchResult.

The last step in the control flow is the action node called Set Title. It has two input objects, userInput and searchResult. The

object userInput also contains the attribute title, which will be assigned to the attribute title of object searchResult.

In this first iteration, you will draw the reading of the XML file and the filtering of the file content, marked in red in the

figure above. As no calculations will be done yet, the output parameter will be a list of products.

Now, start drawing the activity diagram.

Add the input parameter userInput to the

diagram frame.

Place it on the left diagram frame border.

Page 53: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 53

Add the output parameter productList to the

diagram frame.

Place it on the right diagram frame border.

Add an initial node and an activity final node to

the activity diagram. Assign the names Start and

End.

Click the initial node Start and choose the Control

Flow icon from the smart manipulations bar, ...

Page 54: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 54

... draw a new action node ...

... and assign the name Read XML File.

Finally, draw a control flow from action node

Read XML File to another action node Filter File

Content and from there to the activity final node

End.

Page 55: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 55

Save the UML model.

4.4.2 Reading the XML File

The first action calls the activity Read XML File and contains actions to read the XML file and to create the output object

allProducts. To retrieve the data from the XML file you need to use the file system adapter.

Currently, the action node Read XML File has no behavior, that is, an activity that is called at this point. You will now model

the activity diagram that defines the behavior of this action node.

Right-click the action node Read XML File and

select the menu items New Diagram > Activity

Diagram from the context menu.

Page 56: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 56

The Create Diagram dialog window opens,

showing the containment tree.

In the text field Type Activity Diagram name type

in Read XML File. This will be the name the

activity diagram.

Expand the package Data / Services /

QueryProductsService and select the package

QueryProductsPortType.

Note: Make sure to select the package

QueryProductsPortType as the destination

to where the new activity diagram will be

stored.

Click Create Owner and select Activity from the

list.

In the following activity specification dialog,

assign the name Read XML File to the activity,

too.

Close all dialog windows.

Page 57: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 57

The new activity diagram is opened in the

diagram pane. In the containment tree, it is

displayed below the activity having the same

name.

Return to the activity diagram Query

Products. The action node Read XML File is now

linked to the activity Read XML File defining its

behavior.

Page 58: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 58

Right-click the action node Read XML File and

choose Select in Containment Tree.

Note that there is no input or output defined for

this action yet.

Double-click the action Read XML File either in

the containment tree or in the diagram pane to

open the empty activity diagram again.

In the picture below, the completed activity diagram provides an overview of all activities you are going to implement in

Read XML File.

Page 59: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 59

When reading from a file (see action node Read Products XML File), the data is stored in an object data, which is of base

type Blob. A blob is a binary large object that can store a large amount of binary data (e.g. pictures, web pages, and so on).

To read the XML file, you can use the file system adapter that facilitates the file access. All you need to do is to define the

location where the file is stored.

In the activity diagram, you define the action of the file system adapter (for instance read). In the component diagram, you

customize the file system interface (file name and path).

Note: It is also possible to define the path and name of a file dynamically in the activity diagram. For more details

refer to the E2E Bridge Reference Guide.

Note: The output object of the file system adapter when reading a file must always be named data.

After the XML data has been stored in a blob, the binary data is transformed and assigned to the output object allProducts.

The output object is passed to the caller, which is the action Read XML File in the activity diagram Query Products.

Page 60: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 60

Right-click directly into the empty activity

diagram and choose Select in Containment

Tree.

The activity diagram is selected in the

containment tree.

Page 61: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 61

In the containment tree, select the activity Read

XML File and create a new parameter:

allProducts : Catalog (complex type)

direction out

Note: After creating the parameter and

assigning the type, a pin was added to the

caller action Read XML File in the activity

diagram Read XML File automatically.

Place the parameter on the right frame border in

the diagram pane.

Draw the activity diagram as shown in the picture below:

Page 62: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 62

Initial and final nodes:

Start and End

Action nodes:

Read Catalog XML File

Map XML to Objects

Draw all required control and object flows as shown in the picture.

Before finishing the implementation of the two action nodes, you will return to the caller of this activity in order to complete

it.

Go back to the previous activity diagram Query Products by using the Previous Diagram menu icon.

Page 63: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 63

The action node Read XML File calls the activity

Read XML File, which returns the object

allProducts. When creating this parameter for

this activity, a pin was created for the action

node in the containment tree. Currently, it is

not visible in the diagram pane.

In order to make it visible, right-click the action

node Read XML File and choose the menu items

Related Elements > Display Pins.

Page 64: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 64

Select the pin allProducts in the Select Pin dialog.

The pin is displayed in the diagram pane.

Page 65: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 65

As it is an output pin, move it to the right side of

the action node and draw an object flow to the

action node Filter File Content.

In the next step, you will finish the implementation of the activity Read XML File.

Save the UML model.

4.4.2.1 File System Adapter

The Bridge provides several backend adapters like the file system adapter, which you can use to read and write files. The

output of a file system adapter when reading a file is always an object of base type Blob to support all possible data types

(e.g. binary for images, text with HTML tags, XML data, etc.).

Now, you are going to implement the file reading by the help of the E2E Action Wizard.

Return to the activity diagram Read XML File.

Page 66: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 66

Select the action node Read Catalog XML File and

choose E2E Action Wizard from the context

menu..

In the stereotype list select FileSystemAdapter.

Click Next .

Page 67: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 67

The file system adapter can be used for different

purposes, for example, to remove and write files,

or to handle directories. Therefore, you need to

specify the action that the file system adapter

shall perform.

Leave the default action read as you want to read

the file.

Click New to define an alias.

You will now define a pointer that links the

physical definition of the backend in the

component diagram to the logical definition in

the activity diagram, where a file system

adapter as a backend is used.

In this way, an action in the activity diagram

will be enabled to access a backend defined in

the component diagram. Note that the backend

has not been defined in the component

diagram, yet. This will be done later by the help

of the E2E Components Wizard.

Enter the name catalog and click OK and Next .

After finishing the wizard, you can find the alias

definition in the package Data / Aliases.

Page 68: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 68

Remember that the read data is stored in an

object data of base type Blob. This object now is

suggested from the wizard as a parameter.

You do not need any further parameters.

Click Next .

The wizard presents a summary of all

adjustments.

Click Finish .

Often, adapters need to map their standard

input or output objects to other objects having

different names. Such data mappings can be

easily modeled by using pins.

A pin already was created by the E2E Action

Wizard.

Right-click the action node Read Catalog XML

File and select Related Elements > Display

Pins from the context menu.

Page 69: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 69

Move the pin to its final position and draw an

object flow to the next action node Map XML to

Objects.

The stereotype <<FileSystemAdapter>> you have defined on the action node is displayed in blue. The tagged values

action=read and alias=catalog are also displayed. The action is ready to read the XML file using the file system adapter

(once the backend is defined in the component diagram). The alias is used to look up the path and name of the file in the

component diagram.

The content of the XML file will be stored in the object data; no action script needs to be written. When using the file system

adapter, the received data must always be stored in an object named data, which needs to be of base type Blob. The default

character set of a blob object is UTF-8 (see appendix in the E2E Bridge Reference Guide).

Page 70: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 70

Save the UML model.

Page 71: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 71

4.4.2.2 Transforming XML Data

In the action node MAP XML to Objects, you will transform and assign the data of the blob object to the object allProducts.

Use the Action Script Editor to enter the following action script statements.

create allProducts; This statement creates the object allProducts, which is

an instance of class Catalog.

set allProducts = data.xmlToClass(); The operation xmlToClass converts an XML structure to

a class structure. All XML elements are mapped to class

associations, respectively <<XMLElement>> stereotyped

attributes, automatically. The operation is called on the

blob object data containing the XML data.

Page 72: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 72

Note: To make the automatic data mapping of the xmlToClass operation work, the defined class attribute needs to

have the same name as the XML element. In this case, you linked the attribute products of class Catalog to the XML

Element product by specifying the external name product.

For further information about E2E Bridge operations, see E2E Bridge Reference Guide.

Save the UML model.

4.4.3 Filtering the File Content

Entering keywords in the search mask of the Excel client will return all matching records in the XML file. The search mask

supports a maximum of five search keywords. In the model however, you will support an unlimited number of keywords.

Page 73: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 73

4.4.3.1 Outlining the Activity

In the activity diagram Query Products, you will now create the activity diagram that defines the behavior of the second

action Filter File Content. After this step, the activity diagram Query Products will look like shown in the picture below.

Page 74: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 74

You will define the behavior of the second

action using a different approach than for the

first action.

In the package Data / Services /

QueryProductsService / Ports /

QueryProductsPortType, create the new

activity diagram Filter File Content.

MagicDraw will suggest the name of the

PortType. Just overwrite the suggested name.

Note: Creating an activity diagram in the

containment tree, the diagram owner (the

activity) will get the same name.

Go back to the activity diagram Query Products.

Define the behavior of the second action Filter

File Content by right-clicking it and selecting the

menu item Behavior from the context menu.

Choose the new activity Filter File Content from

the list.

Open the activity diagram Filter File Content, and draw all elements displayed in the picture below. The activity diagram will

contain all activities to filter the content of the XML file according to the search parameters entered in the Excel client.

Page 75: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 75

In the following, you find a list of the elements you need to create the activity diagram Filter File Content:

Initial and final nodes:

Start and End

Input parameter:

userInput : SearchParameters, Direction in

allProducts : Catalog (complex type), Direction in

Output parameter:

filteredProducts : Catalog (complex type), Direction out

Action node:

Create a Pattern of Keywords

Filter File Content

After creating the parameters, the input and output pins of the calling action were generated automatically in the

containment tree. Return to the activity diagram Query Products.

Page 76: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 76

The object flow of the input object is already

drawn. Therefore, there is no need to make the

generated input pin visible.

In order to make the output pin visible, right-

click the action node Filter File Content and

choose the menu items Related Elements -

Display Pins from the context menu.

Select the pin filteredProducts from the Select

Pin dialog.

To make it more obvious that the pin is an output

pin, move it to the right side of the action node.

Page 77: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 77

The value of the pin filteredProducts is used as

output of the SOAP operation for the time being.

Draw the required object flow from the pin to the

output parameter productList.

Also, draw the object flow from the input

parameter userInput to the action Filter File

Content.

Save the UML model.

4.4.3.2 Creating Keyword Patterns

In the next step, you will draw the activity diagram that addresses the keywords search. On the Excel client, the user may

fill in no, some, or all keywords in the search mask. Upon his input you have to decide what has to be done next. This

decision will be modeled with a decision node. If no keyword has been entered, all rows will be selected. If one or more

keywords have been entered, a row will be selected if at least one of the keywords matches the title.

You will create an internal array object keywordsArray, which will contain all keywords the user has entered in the search

mask. If the number of array elements is zero, you will create a string object called keywordsPattern that does not contain

any keywords. Otherwise, you will assign a value to this string object that contains all given keywords within regular

expressions. The string keywordsPattern will be used for filtering the rows later.

Regular expressions are used to find search patterns in a string. You will use this technique in this example to find

keywords in the field title of each product record.

This will be all implemented in the activity Create a Pattern of Keywords. Create a new behavior activity diagram Create

Keywords Pattern in the package QueryProductsPortType and assign it to the action node. Double-click the action node to

open the empty activity diagram.

First, you will outline all actions of the activity diagram.

1. First, you filter out all empty keywords. The result is stored in an array.

2. In the decision node, the number of keywords in the array is evaluated.

3. If the array is empty, an empty pattern is created. No further action is executed.

4. If the array is not empty, another pattern is defined using the keywords in the array in the following two actions.

Page 78: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 78

Create the outline of the activity diagram as shown in the picture above.

Initial and final activity node:

Start and End

Action nodes:

Collect Non-Empty Keywords

Set Keywords Pattern

Finalize Keywords Pattern

Create Empty Pattern

Decision node:

CheckEmpty (see section below on how to draw a decision node)

Input parameter (stores the search parameters passed from the client):

userInput : SearchParameters (complex type), direction in (copy parameter from activity Filter File Content)

Output parameter:

keywordsPattern : String (base type), direction out.

Central buffer nodes:

keywordsArray : Array (base type) (see section below on how to define an array)

keywordsPattern : String (base type)

Page 79: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 79

Draw all control and object flows as shown.

4.4.3.2.1 Decision nodes

In the decision node, you need to decide whether

the keywords array from parameter userInput is

empty.

Select a Decision/Merge icon from the diagram

toolbar and place it on the activity diagram.

Double-click it to open the Decision Node

specification dialog and assign the name

CheckEmpty.

Page 80: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 80

4.4.3.2.2 Arrays

The object keywordsArray is an array, which can contain an unlimited number of String elements. If an array is drawn in

the activity diagram, you always need to define the type of its array elements.

Double-click the object keywordsArray to open

its specification dialog. Set the Type to Array,

which is a base type.

Each array must be stereotyped as an array.

Select the stereotype E2EArray in the Applied

Stereotype field.

Setting this stereotype, the new field Array Element is displayed. Define the base type String as type of the array elements.

The type of the array elements is visible now in

the second line of the object node.

Page 81: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 81

4.4.3.2.3 Collecting Non-Empty Keywords

Open the Action Script Editor for action Collect Non-Empty Keywords and define the action script to process the five

keywords passed from the client.

create keywordsArray;

set keywordsArray = select each from userInput.keywords where element != "";

Note: Arrays always need to be created with the create statement.

Note: When typing the select keyword followed by a blank, the statement will be completed except the object and

the condition in the where clause.

The operation select each from processes every element of array keywords, which is an attribute of input object

userInput.

By defining the condition where element != "", the operation only considers keyword fields, which the user did not

leave empty in the search mask (read: array element that does not equal an empty string).

All keywords that are found in the array keywords and match the condition will be copied to the array keywordsArray.

Page 82: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 82

4.4.3.2.4 Counting Elements of the Array

If no keywords are passed from the client, the flow branches from the decision node CheckEmpty to the right. As you

copied all keyword fields, which have not been empty, from the input object userInput to the array object keywordsArray,

you can now count all elements. If the array has no elements the flow will branch to the right.

Double-click the control flow that branches to the right. Name the control flow empty and enter the following condition in

the Guard field.

keywordsArray.count() < 1 The count operation counts all elements in the array

object keywordsArray. The condition is true, if the array

has no elements (less then 1).

As an alternative, you can edit the guard statement with the Action Script Editor which gives you more control of the

syntactical correctness. Select the control flow and press Ctrl - Enter to start the Action Script Editor.

Page 83: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 83

4.4.3.2.5 Creating an Empty Pattern

Open the Action Script Editor for action Create Empty Pattern. Add the action script that assigns a regular expression to the

string object keywordsPattern. Later on, this regular expression stored in the string will be used to select all rows,

because no keywords were entered. See detailed information about regular expressions in chapter Regular Expression in

the E2E Bridge Reference Guide.

Operators of Regular Expressions Description

. Match any character.

* Match 0 or more times. Match as many times as possible.

set keywordsPattern = ".*"; Assigns the regular expression .* to the output string

object keywordsPattern. The search pattern .* will find

all characters of a string, which means that in the search

every title will match (all records will be returned).

Page 84: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 84

4.4.3.2.6 Second Branch of the Decision Node

If at least one keyword is passed from the client, the flow branches from the decision node CheckEmpty downwards.

Remember, that the flow branches to the right, if the number of elements of array keywordsArray is less than 1. If this

condition is not true, the flow branches downwards.

Double-click the object flow, name it not empty, and enter else in the Guard field.

else else represents all other cases that were not specified

explicitly.

In the next step, you will construct a search statement with regular expressions in the action state Set Keywords Pattern.

The search pattern will also be stored in the string object keywordsPattern and contains all keywords found in the array

keywordsArray.

4.4.3.2.7 Setting the Keyword Pattern

Open the Action Script Editor for action Set Keywords Pattern. Add the action script below that assigns a regular

expression to the string keywordsPattern. Later on, the search pattern will be used to select all matching rows according

to the keywords that were passed from the client.

Page 85: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 85

Operators of Regular Expressions Description

. Match any character.

* Match 0 or more times. Match as many times as possible.

| Alternation. A|B matches either A or B.

set keywordsPattern = reduce keywordsArray using element.concat(".*|.*", nextElement) if

single use element;

The statement reduce ... using concat collects all elements of an array in a simple string. When iterating over the

array keywordsArray, element and nextElement are placeholders for the current and the next array element of each

iteration.

element, ".*|.*", nextElement builds a list composed of a combination of keywordsArray elements and the

regular expression .*|.*. If the array contained only one element, the resulting string would only contain the value of this

element (defined by if single use element). Below, you will find an example on how this regular expression works.

Page 86: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 86

4.4.3.2.8 Finalizing the Keywords Pattern

To finish the activity diagram, complete the search statement by concatenating another regular expression at the beginning

and at the end of the string object keywordsPattern. In this activity diagram, this is the last step in the action flow.

Open the Action Script Editor for action Finalize Keywords Pattern and enter the statement below.

set keywordsPattern = concat(".*", keywordsPattern, ".*");

The operation concat concatenates the regular expression .*, the current value of keywordsPattern, and the search

pattern .* a second time. The new value will be re-assigned to the string keywordsPattern.

The following shows an example of a resulting value in the string object keywordsPattern:

Three keywords are passed as input from the client (userInput.keywords):

nemo

lord

pirates

Value of string keywordsPattern, which will be used to search in each element title (compare action scripts in action

node Set Keywords Pattern and Finalize Keywords Pattern):

Page 87: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 87

.*nemo.*|.*lord.*|.*pirates.*

How to read the regular expression:

Match any character as many times before and behind nemo, or any character as many times before and behind

lord, or any character as many times before and behind pirates.

In other words:

If any of the three keywords will be found anywhere in the title, then the search pattern matches, and the row has to

be selected.

The activity has been completed.

In order to make the model more readable and to prevent crossing object or control flows, MagicDraw offers a functionality

to split flows. Follow the following steps to split the control flow from the action node Create Empty Pattern to the activity

final node.

Page 88: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 88

Right-click the control flow and select the menu

item Split Control Flow from the context menu.

The control flow is now split and has two new

ends. The round symbol ( ) marks the points

where the control flow is bridged. Rearrange the

control flow ends according to the picture on the

left.

Save the UML model.

4.4.3.3 Finalizing the Activity Diagram Filter File Content

Return to the activity diagram Filter File Content. Define the output object for action Create Keywords Pattern, whose

behavior you just implemented. The output is the search term keywordsPattern that will be used to filter the data.

When you defined the parameters of the activity Create Keywords Pattern, the input and output pins for the calling action

were generated automatically. As the input object userInput is already drawn for the action Create Keywords Pattern, you

only need to make the output pin visible.

Select the action node Create Keywords Pattern and choose the menu items Related Elements > Display Pins from the

context menu.

Page 89: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 89

Only select the output pin keywordsPattern.

Page 90: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 90

Draw an object flow from output pin keywordsPattern to action node Filter File Content, which needs this string as input.

Save the UML model.

Page 91: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 91

4.4.3.4 Filtering the Content

Now, you will use the search term, which you have stored in the object keywordsPattern in the previous steps. In the action

node Filter File Content, the actual search will be performed. Enter the statements below to the action script of the action

node Filter File Content.

create filteredProducts;

set filteredProducts.products = select each from allProducts.products where

element.title.toLower() like keywordsPattern.toLower();

The operation select each from processes every element of array products, which is an attribute of input object

allProducts. The search terms are applied to element.title, which is explained as follows. element temporarily

stores array elements of array products, which are of type Product. The class Product has a string attribute title, which is

considered in this search (compare also to the data structure, which you defined in the class diagram).

The search term is stored in the string keywordsPattern, which you prepared before. toLower() will set all characters of

the search term and title elements to lower case as the search should not be case sensitive. Array elements that match the

search pattern according the where clause (where element.Title.toLower() like

keywordsPattern.toLower()) will be stored in the attribute products (base type array) of object filteredProducts ( set

filteredProducts.products =).

Save the UML model.

Page 92: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 92

4.5 Component and Deployment Diagrams

In the picture below, the component diagram, which results from the work in lesson 2, is displayed. The component

diagram will be extended now by using the E2E Components Wizard. You will specify a File System Component in the

Composite Service Education.

After running the E2E Components Wizard, the component diagram will look like shown in the following picture.

The deployment diagram will be extended, too, as the deployment for the file backend has to be defined. The artifact

instance (the copy of the artifact FileSystemServiceArtifact) will be deployed to node instance localhost. After extending the

deployment diagram with the E2E Deployment Wizard, the diagram will look like shown below.

Page 93: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 93

4.5.1 Reworking and Extending the Component Diagram

For extending the existing configuration you created in lesson 2, you will use the Components Wizard to define a file

backend. But first, you will do some renaming.

Open the component diagram EducationComponents in node Component View of the containment tree.

Rename the Composite service and the

Service artifact EducationLesson2 and assign

the new name EducationLesson3.

Change the control port of the service

artifact to 20013.

Rename the Service Component and the

Component artifact GetProductService and

assign the new names

QueryProductsServiceComponent and

QueryProductsServiceArtifact.

Change port number of the service component

artifact to10013.

Delete the port type definition

GetProductPortType and the artifact

GetProductPortTypeArtifact.

Use Ctrl - D for the deletion, as you not only

want to delete the symbol from the diagram

pane, but also the port type definition from the

containment tree.

Page 94: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 94

Click the icon Edit Component Diagram

from the diagram toolbar to start the

Components Wizard.

Do not use the icon E2E Components Wizard in

the MagicDraw menu bar, as this would create

a new component diagram.

The E2E Components Wizard dialog window opens.

The wizard displays the Service Component

EducationLesson3 and the composite artifact

EducationLesson3.

Expand the tree on the left and navigate to the

component QueryProductsService Component

below the Customized Artifacts node of the tree.

The wizard shows the new artifact

QueryProductsPortTypeArtifact.

Page 95: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 95

Select QueryProductsPortType and click > to

create composite and an artifact.

Leave the name QueryProductsPortTypeArtifact

and click OK .

In the customization panel on the right, you will

find the new port type artifact

QueryProductsPortTypeArtifact.

The port type artifact QueryProductsPortType-

Artifact manifests the port type class

QueryProductsPortType.

In the Customized Artifacts part of the tree panel,

the composite artifact is selected again, to give

you the option to define further frontend services.

But you now have completed the frontend of your

Web Service for lesson 3. Click Skip .

Page 96: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 96

As the Web Service will read data from an XML file, you need to define a backend. As you read a file using the file system

adapter, you need to define a file system service in the component diagram in order to access the XML file. Then, you need

to define a backend interface for this file system service. Finally, you determine which Composite service will be connected

to which backend by the use of dependencies. You will add the alias defined in chapter File System Adapter to this

dependency, in order to link the physical definition of the backend with the logical definition in the activity diagram, where

the backend adapter is used.

Choose the option Backend Services in the Skip

dialog.

In the Customized Artifacts tree of the tree panel,

the tree node Backend Services is selected.

Click New to create a new backend service

component.

From the list of backend service stereotypes,

choose FileSystemService.

Page 97: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 97

Create the file system service artifact and assign

the name FileSystemService- Artifact, which is

the default name suggested.

Click OK.

The file system service artifact

FileSystemService- Artifact manifests the service

component FileSystemService.

Click Next .

In the next step, you need to define a backend

interface that knows where the XML file is

located. To create a new backend interface

component, click New.

Page 98: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 98

To file system interface artifact assign the name

XMLFile.

When defining the interface artifact, you specify

the path where the XML file is physically located

on the machine where the file is deployed.

Remember, that in the beginning of this lesson

you were asked to keep the file path in mind

(default location C:/E2EBridgeDocumentation_5/

Docu- mentation/pdf/E2E Education/Lesson3).

Enter the file name catalog.xml and the path in

the appropriate fields.

Click OK.

The file system interface artifact XMLFile

manifests the interface component XMLFile.

Click Next .

Page 99: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 99

The definition of the backend file system service

is complete, but the dependency is still missing.

Click Skip .

Choose the option Dependencies in the Skip

dialog.

In the next step, you will specify the connection

between the Composite Service and the

previously defined backend interface. The

connection is established by defining a

dependency.

Starting point of the dependency is the service artifact EducationLesson3. Note that in the tree panel, this is the parent

element of the Dependencies element.

Ending point of the dependency is the backend interface artifact XMLFileArtifact. Select it from the list Point Dependency to

on the left and click the button > .

For each dependency, an alias needs to be defined. The alias is a pointer that links the physical definition of the backend

with the logical definition in the activity diagram, where the backend file system adapter is used. By defining an alias on the

Page 100: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 100

dependency, a file system adapter in the activity diagram, which is using the same alias, will know the name and the path

of the file.

You already defined the alias catalog in chapter File System Adapter. The alias catalog is already selected in the Alias field.

The dependency is drawn as an arrow from the

Composite Service artifact to the backend

interface artifact in the component diagram.

Besides the alias, further tagged values may be

defined for the dependency. In this example,

you do not need to enter further tagged values

for the dependency. The name is optional, too.

Click OK to proceed.

You defined a dependency using the alias catalog.

The content of the XML file catalog can be read

and processed in the activity diagram that is

using the file system adapter, to which the same

alias is applied.

Click Next .

Page 101: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 101

All necessary components and artifacts have

been defined. Therefore, the wizard skips to the

final step. You need to confirm drawing the

component diagram.

Click Finish .

As of changing the component diagram, some

data needs to be reloaded by the Model Compiler.

Click Yes to refresh the deployment data and

save the UML model.

The component diagram will be re-drawn in MagicDraw. The defined components and artifacts are saved in the package

Data / Component View.

The generated component diagram will open and the Builder will report the error "Missing Backend Service

'FileSystemServiceArtifact' in Deployment Diagram 'EducationDeployment'..". The missing deployment backend will be

created in the next chapter.

The composite service artifact EducationLesson3 has the SOAP service artifact QueryProductsServiceArtifact and its port

type artifact QueryProductsPortTypeArtifact.

At the backend side, the backend service artifact FileSystemServiceArtifact has been created together with its interface

artifact XMLFileArtifact. The dependency from Service artifact EducationLesson3 to the file interface artifact displays the

tagged value alias with the assigned value catalog.

Remember that the Quick Diagram Layout helps you to route the paths in orthogonal style.

Page 102: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 102

In the next step, you will extend the deployment diagram with the E2E Deployment Wizard.

4.5.2 Extending the Deployment Diagram

The deployment diagram changed automatically, when you renamed the Composite Service artifact. The artifact instance (a

copy of the Composite Service artifact EducationLesson3) will be deployed to node instance localhost.

Still, as the Service will call a backend (it will read the XML file), you need to define this backend in the deployment

diagram. The XML file is located on the node instance localhost.

For extending the existing deployment you created in lesson 2, you will use the Deployment Wizard. Once the deployment

diagram is finished, it will look like shown in the following picture.

Page 103: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 103

Open the deployment diagram

EducationDeployment from File View -

EducationDeployment in the containment tree

and click the icon Edit Deployment

Diagram from the diagram toolbar to start the

Deployment Wizard.

Do not use the icon E2E Deployment Wizard in

the MagicDraw menu bar, as this would create

a new deployment diagram.

The E2E Deployment Wizard dialog window opens.

The wizard asks to select a configuration

artifact. As this is already done and the name of

the deployment diagram cannot be changed,

click Next .

Page 104: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 104

In the tree panel of the wizard, the tree node

localhost is displayed. If you expand this tree

node, you will find the artifact instance

EducationLesson3, which is deployed to node

instance localhost.

As you will define the backend node instance, click

Next .

Select the node instance localhost and click the

button > to choose it. The node instance will

become a backend node instance, too.

Now, the tree node Backend Server is selected in

the tree panel of the wizard.

The wizard recognizes that a node instance

(localhost) has already been defined. It will not

only be used to host an E2E Server, but also to

host a backend as well (in this case the file

system).

localhost is used as E2E Server node and backend

node at the same time.

Click Next .

An instance of the file system service artifact will

be deployed to node instance localhost.

Select the artifact FileSystemServiceArtifact and

click > in order to deploy it to localhost.

Page 105: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 105

The artifact instance FileSystem ServiceArtifact is

shown on the right side of the customization

panel.

Note: Artifact instances are displayed bold

and underlined. If an artifact instance

already exists in the UML model and has

not yet been added to a backend node

instance for deployment, it will also be

listed on the left side of the customization

panel.

Click Next .

This is the final step of the Deployment Wizard.

You need to confirm drawing the deployment

diagram.

Click Finish .

As of changing the deployment diagram, some

data needs to be reloaded by the Model Compiler.

Click Yes to refresh the deployment data and save

the UML model.

The deployment diagram will be re-drawn in MagicDraw. The defined node and artifact instances are saved in the package

Data / File View.

The generated deployment diagram will open.

Page 106: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 106

Now, the Composite Service EducationLesson3 can be compiled.

Page 107: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 107

4.6 Compilation

You can now compile and deploy the UML model and complete the first development iteration. Change to the Model

Compiler window and expand the file lesson3.xml in the deployment view.

Compile the Composite Service

EducationDeployment.

If everything is ok, the XMI file name and the Composite Service's name will turn green. If an error occurs, the name of the

Composite Service will turn red. Double-clicking the error in the E2E Messages window will highlight the package or the

UML element in the containment tree of MagicDraw where the error occurred. Try to correct the error in the UML model

and compile the Composite Service again.

Page 108: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 108

4.7 Solving Errors

If no error has been reported, skip this chapter.

If you cannot fix the problem, open the Builder

project E2E Education (default location

C:\E2EBridgeDocumentation_5\

E2EBuilderProjects).

Click OK .

If you not have opened this project before, the

E2E Builder File Chooser pops up. Select the file

lesson3_first.xml in sub folder uml, which

contains all reference models of the first

iteration.

If you already studied the solution models in lesson1 or 2, the builder will automatically open the model file last used.

Page 109: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 109

Close the open project. Switch to the File View

tab of the Model Compiler and double-click the

file lesson3_first.xml to open it.

You can compare the solution model with your model to find the error. Remember, that you can switch between open

project files using the Opened Projects toolbar of Magic Draw.

Note: By loading lesson3_first.xml from Builder Project E2E Education your own project Education is no longer the

active Builder project, though your own XMI file lesson3.xml is held open within Magic Draw. Wanting to continue

working with Education, you will have to reopen the project.

See chapter Solving Errors in the lesson 1 or 2 document to get further information on how to change the active Builder

project..

As an alternative, you can continue your studies with the solution model by importing the solution into your own Builder

project.

Compile the imported model and continue with lesson 3.

See chapter Solving Errors in the lesson 1 or 2 document to get further information on how to import an xml document into

your active Builder project.

Page 110: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 110

4.8 Testing with E2E SOAP Test Tool

Now, you can test the Composite service with the E2E SOAP Test Tool.

4.8.1 Testing the File Reading

Start the service with Run "Education

Deployment" in the Compiler window.

The log view shows the service having been deployed to the internal server of the development environment and now

running in the E2E Embedded Server.

Open the E2E SOAP Test Tool by clicking Open Test Case . The SOAP Test Tool window opens and shows a test case for

lesson3.EducationLesson3.EducationDeployment.

Page 111: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 111

Have a look at the default test case queryProducts. The gearwheel in gray color indicates that the test case has not yet

been run. On the Request tab in the right panel, the input parameter userInput is displayed.

Remember, that parameters of complex type have to be created by a create statement. Create the parameter

userInput by selecting Create from the context menu.

Expanding userInput, the title field and the keywords array are displayed. Arrays are labeled with the icon an have to

be created, too.

Create the keywords array.

The keywords array has been created as an array with no elements. This is indicated by the phrase String[0] in the

parameter's tree node. You could append array items now, but in this first step you will not test the filtering functionality.

Run the test case without entering keywords. The Analyzer switches to the Response tab and shows the result.

Page 112: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 112

If the test case reports no error, the test case's gearwheel will turn green and all eight products from the file

catalog.xml should be displayed.

If an error occurred, the gearwheel turns red. Go on reading this page, even if no error occurred.

In case of an error, open the detail node on the Response tab. Expand the first message node to read the description of the

error.

The message might read: Failed stating file “C:/E2EBridgeDocumentation_5/Documentation/pdf/E2E

Education/Lesson3/catalog.xml”.

This means, that the data source file catalog.xml could not be found in the location you defined in the backend interface

artifact XMLFileArtifact in the component diagram.

To solve the problem, copy the file catalog.xml to the location you have defined in the component diagram (default location:

C:\E2EBridgeDocumentation_5\Documentation\pdf\E2E Education\Lesson3. As an alternative, you can also check the

current location path of the file and adjust the path in the backend interface artifact XMLFileArtifact in the component

diagram. In this case you must compile and deploy the Composite service again. This applies also, if there are typing

errors in the file's path name.

After your corrections, run the test case again.

The attribute of the output object productList (product array, labeled with ) is displayed. The array elements, which are of

type Product, contain all product records retrieved from the XML file. The name of the array product is being followed by

the number of array elements (8) in square brackets: product: Product[8].

4.8.2 Testing the Filtering

Now, you will create a second test case to test the filtering functionality of your Composite service.

Create a second test case.

Page 113: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 113

Assign the name queryProductsFiltering.

Create the parameter userInput.

Note: Normally, you will create the array in the SOAP Test Tool first, which results in an empty array. As, in this case,

you want to add an array element, you can directly append an element without creating the array before. The SOAP

Test Tool will create the array automatically.

As keywords is an array, you need append an array element for each

keyword you want to enter.

Click keywords with the right mouse button and select Add Item in the

context menu. Append an array element for each keyword you wish to

enter and type in some values.

Run the test case.

On the Response tab, expand the tree. The records shown in the picture below will be selected if you used the keywords

Nemo, Lord, and Pirates on the Request tab.

Page 114: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 114

Page 115: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 115

5 Second Iteration

Now, after the file reading and filtering is implemented, you will extend the service as to covert the price of the products to

CHF. The exchange rate needed will be taken from an external web service.

Furthermore, you will calculate the total price and a delivery charge, and set the title of the spreadsheet.

Page 116: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 116

5.1 Class Diagram

You now will extend the class diagram with the necessary properties for the exchange rate conversion and the other

calculations.

Switch to the class diagram Product Query Classes, right-click into the diagram pane and choose Close All Diagrams But

Current.

The class diagram as it is describes the structure of the XML file and provides the input parameters. It is not possible to

add the additional properties directly to the class Product, because the additional properties are not part of the XML file.

Therefore, you will create a new class ProductExtended that will contain all attributes of class Product and the additional

attribute priceCHF as well.

Page 117: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 117

Pick the class icon from the diagram toolbar and draw a third class ProductExtended as shown above.

Page 118: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 118

Select ProductExtended and choose

Generalization from the smart manipulation

tool bar.

Draw a Generalization from ProductExtended to

Product so that ProductExtended inherits all

attributes of Product.

Page 119: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 119

Double-click ProductExtended to open the

Specification dialog and switch to the tab

Attributes.

Note the list of attributes ProductExtended

inherited from Product and via Product from

Catalog.

Create a new attribute priceCHF with type Float

and visibility public.

Click Back .

Page 120: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 120

Note the new attribute priceCHF at the top of the

list of all attributes of ProductExtended.

Click Close .

Your class diagram now should look like the one below.

Page 121: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 121

To give back some more calculated information in addition to the products, you need a fifth class.

Draw another class and assign the name SearchResult.

Add the following attributes to class SearchResult:

Attribute Name Attribute Type Visibility

deliveryCharge Float public

exchangeRate Float public

keywords String public

title String public

Page 122: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 122

Attribute Name Attribute Type Visibility

totalAmountCHF Float public

totalAmountUSD Float public

SearchResult will be the type of the return parameter of the port type operation. That is why you will link the product

information to SearchResult.

Draw an association from SearchResult to

ProductExtended.

Open the Specification dialog of the association.

Assign the name contains as the SearchResult

contains ProductExtended.

To Role of ProductExtended assign the name

matchingProducts, set the multiplicity to 0..* and the

visibility to public.

Set the multiplicity of Role of SearchResult to 1.

Now, compare the link between SearchResult and ProductsExtended with the link between Catalog and Product.

Page 123: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 123

The SearchResult contains zero to infinite matchingProducts and some additional information. Association end

matchingProducts constitutes an attribute of class SearchResult. It is an array that contains elements of type

ProductExtended.

Save the UML model.

Page 124: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 124

5.2 Activity Diagram

5.2.1 Outlining the Activity

First, you will extend the Activity diagram Query Products of the port type operation.

Open the activity diagram Query Products.

After the second iteration the QueryProductsService will provide more output than just the list of products.

Draw two action nodes as shown below to complete the control flow of activity diagram Query Products.

Page 125: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 125

Remove the output parameter productList

from the diagram as well as from the

containment tree as it is not needed any

longer.

Also remove it from the port type operation

queryProducts.

Then, move the output pin filteredProducts as

shown on the left and connect it to Calculate

Total and Currencies.

Page 126: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 126

Add a new the output parameter searchResult of

type SearchResult to the port type operation

queryProducts.

Define it as of type SearchResult and direction

out.

Note that the parameter of the related activity

was created automatically. Check the direction of

this automatically created parameter and set it to

out if necessary.

Drag and drop the parameter searchResult on the diagram border and the activity parameter node will be created

automatically, too.

Page 127: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 127

In the last step, you will set the title to be displayed in the Excel client in the action node Get Title. It will be assigned to the

corresponding attribute in the output object searchResult.

You need to set the value of attribute title of object searchResult. Therefore, the object is used as input of the action node

Get Title. Connect the input parameter userInput to the action node GetTitle.

As you change an attribute of the object searchResult, you need to draw an object flow from the action node to the activity

parameter node searchResult. The object will be passed to the caller, the port type operation queryProducts.

Page 128: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 128

Finally, add the following action script to the

action node Get Title.

set searchResult.title = userInput.title;

Save the UML model.

Page 129: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 129

5.2.2 The Currency Calculator

Before creating new activity diagrams, you should analyze some reuse options to reduce investments in time. The class

CurrencyCalculator from the lesson 2 model can also be useful in lesson 3. You are going to copy it from lesson 2 and

extend it afterwards.

Open the activity diagram Get Product in package Data / Services / GetProductService / Ports / GetProductPortType.

In lesson 2, you created the activity diagram Get

Product containing the call operation action

getExchangeRate of class CurrencyCalculator.

Navigate to the activity node Get Exchange Rate

in the containment tree and double-click it to

open the corresponding activity diagram.

Page 130: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 130

In action node Define Exchange Rate in the activity

diagram, the exchange rate is set to a fix value.

You will reuse the class operation

getExchangeRate as you will perform currency

conversions in this lesson, too. The hard coding

will be substituted by a call of an external web

service.

Drag and drop the whole class CurrencyCalculator

from GetProductService to QueryProductsService

to the package Classes.

Close the diagram Get Exchange Rate.

Page 131: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 131

Now, you are going to extend the class CurrencyCalculator as to calculate a new price from a given price and exchange

rate. This will be implemented in a new operation calculatePrice. For such small calculations, the E2E Model Compiler

offers the possibility to insert action script directly into the operation without drawing a behavior diagram. The only

restriction is that one parameter of direction return must be defined.

Right-click class CurrencyCalculator in the

containment tree and select New Element >

Operation.

Page 132: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 132

Assign the name calculatePrice.

Define three parameters of the operation as listed

below.

Pay attention to defining the return parameter

newPrice as of type return.

name type direction

price Float in

exchangeRate Float in

Page 133: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 133

newPrice Float return

Double-click calculatePrice to open the

specification dialog.

Apply the stereotype Action Script to the operation

and define the operation as to be static.

Click Close .

Page 134: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 134

Next to the operation name calculatePrice the icon

is displayed to indicate the stereotype.

Select E2E Action Editor from the operation's

context menu to directly add the action script to

the operation.

Enter the set-statement as shown on the left and

click OK.

This statement is a combination of the set-statement with an if-clause. If parameter price exists and contains a valid

value, the calculation price * exchangeRate is executed and the result is assigned to return parameter newPrice. In

all other cases (else), newPrice is set to -1.0.

The newly defined static class operation calculatePrice will be used in the calculations part Calculate Total and Currencies

of your model. You are going to call this operation directly from an action script without creating an object of type

CurrencyCalculator first.

Therefore, you have to make it available to be used within action script. This is done via a <<use>> dependency from the

port type QueryProductsPortType to the used class.

First, create a new class diagram in the package Classes.

Page 135: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 135

Select New Diagram > Class Diagram from the

context menu of the package Classes.

Assign the name Using Static Operations.

Drag the class CurrencyCalculator onto the diagram pane.

Page 136: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 136

Drag the port type class QueryProductsPortType onto the diagram pane.

Select the class symbol of

QueryProductsPortType and - with help of

the smart manipulation toolbar - draw a

<<use>> dependency to class

CurrencyCalculator.

Page 137: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 137

Open the specification dialog of the <<use>>

dependency and assign the name

useCurrencyCalculator.

Click Close .

Via the <<use>> dependency useCurrencyCalculator all static operations of CurrencyCalculator are now available in any

action scripts that are part of QueryProductsPortType.

Save UML model.

Page 138: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 138

5.2.3 Using the SOAP Adapter

To implement the currency calculations, you need the exchange rate from USD to CHF. As mentioned before, you now will

get this exchange rate from an external web service, the E2E Education Exchange Rate Provider.

Web Services are self-contained applications that can be published and invoked across the Web using XML-based

protocols. The E2E Bridge has a "Simple Object Access Protocol" (SOAP) adapter ready, which enables you to use any other

Web Service as backend for the Bridge. Instead of reading data from a database, the SOAP adapter sends a request to the

other Web Service and gets back a SOAP response message. This message then is mapped to data items.

The steps involved in calling a Web Service through the Bridge are as follows:

a client requests the Bridge Web Service

the Runtime then makes a HTTP/SOAP call to the linked Web Service

the result is mapped to the defined data structure

the output is then sent back to the client

Each Web Service has its own distinct interface, defined by the names of the operations and their parameters. Before an

external Web Service can be used, its interface definition must be imported to the UML model or from a "Web Services

Description Language" (WSDL) document. This functionality is implemented in E2E Builder (also see the E2E Builder User

Guide).

During the importing process of the WSDL, you can decide wether to create a test model to test the external service or

wether to import it into an existing UML model.

The WSDL file provides all necessary information to create an UML model, so the test model contains all necessary

building blocks for you to test the imported service.

5.2.3.1 Creating a Test Model for the Imported Service

You can create a test model by importing a WSDL or XML Schema file (XSD) directly from a file or via a URL. As it is more

convenient, you will import the WSDL from the included file ExchangeRateProvider.wsdl.

Page 139: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 139

Select Import > Import WSDL / XSD File from

the E2E Compiler window.

Navigate to the WSDL file. It is located by default

at C:\E2EBridgeDocumentation_5

\Documentation\pdf\E2E Education \Lesson3.

Select it and click OK.

The Builder offers the two options to import into

an existing model or create a new (e.g. test)

model for the imported service WSDL.

By importing into a test model, you get an

overview over the operations provided by the

imported service and you can test them.

Select the second option Import Into a New Model

and click Yes .

Page 140: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 140

A dialog opens for you to enter the name of the

test model.

Change the default name to

ExchangeRateProviderTest.xml and click OK.

Within Builder project Education, a new xml file ExchangeRateProviderTest.xml was created. You can switch between the

test model and lesson3.xml using the Opened Projects Toolbar.

Page 141: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 141

But the new composite service is not ready to be compiled yet, because the component and deployment diagrams are

missing. During the import, the Model Compiler read all necessary components and instances from the WSDL file and

created the packages Component View and Deployment View where all elements of a component and deployment diagram

will be saved.

As ExchangeRateProviderTest.xml has no deployment definition yet, it is only visible in the File View of the E2E Compiler

window.

To create the component and deployment diagrams, use the E2E Component respectively Deployment Wizard.

5.2.3.2 Creating the Logical View with the E2E Component Wizard

Now, start to create the logical view of the imported Web Service with the help of the E2E Component Wizard. Select the

menu icon E2E Component Wizard to start the wizard.

Assign the name TestComponents to the

component diagram and click Next .

Click New to define the Composite component

and artifact.

Page 142: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 142

Assign the name TestArtifact to the Composite

artifact. The corresponding Composite

Component will be created automatically.

The Control Port is used by the E2E Console to

control the deployed Composite service. Leave

the value 21111 and switch to the Advanced tab.

Enter the category E2E Education and click OK.

Page 143: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 143

The TestComponent and TestArtifact are defined.

Click Next to proceed.

Click New to define the frontend service of the

Composite service.

As you model a web service, select

E2ESOAPService from the list of stereotypes.

Click OK.

Page 144: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 144

Enter the name TestServiceArtifact and leave the

default setting of the port to 11111.

Click OK.

In the customization panel on the right, you will

find the new service artifact TestServiceArtifact.

Click Next .

Page 145: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 145

Now, define the interface of the SOAP service.

Select the predefined port type

GetExchangeRatePortType and click > to create

the port type artifact.

Leave the name of the port type artifact to

GetExchangeRatePortTypeArtifact and click OK.

As you do not need to define further frontend

services, click Skip .

Page 146: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 146

The external SOAP Service will be accessed via a

backend definition.

Select Backend Services and click OK.

The Backend Service's components were created

during the import process.

Select the service artifact GetExchangeRate

ServiceArtifact, which is marked in bold and

underline.

Click > to use it.

Backend definition is complete.

Click Skip to proceed.

Page 147: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 147

The SOAP dependency is still missing yet.

Select Dependencies and click OK.

Select GetExchangeRatePortType as target of the

dependency.

Click > .

Page 148: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 148

The Create New Dependency dialog opens. It is

not necessary to assign a name to the

dependency.

Click OK.

The dependency starting at TestArtifact now

points to the alias of the port type

GetExchangeRatePortType.

Click Next .

Page 149: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 149

Confirm the drawing of the component diagram

by clicking Finish .

Click Yes to refresh the deployment data and

save the UML model.

The component diagram is drawn in MagicDraw and the generated diagram TestComponents will open.

Page 150: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 150

Use Route Paths Orthogonal Style from the diagram pane menu to

rearrange the paths of the diagram.

You might want to rearrange the components as shown below.

Page 151: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 151

5.2.3.3 Creating the Physical View with the E2E Deployment Wizard

Now, create the physical view of the imported Web Service with the help of the Deployment Wizard. Select the menu icon

E2E Deployment Wizard to start the wizard.

Enter TestDeployment as a name for the

deployment diagram.

Click Next .

Page 152: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 152

Select E2EBridgeServer and click > to create a

new node instance to which the service will be

deployed.

Keep localhost as name of the physical machine

on which the service will be running.

Click OK.

Click Next to proceed with the backend definition.

Page 153: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 153

Select services.e2ebridge. com, the backend node

that was already created automatically during the

WSDL import.

Click > to create a backend node instance.

Click Next to proceed.

Confirm the drawing of the deployment diagram

by clicking Finish .

Click Yes to refresh the deployment data and

save the UML model.

Page 154: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 154

In the deployment diagram, you can see the Bridge Server Instance localhost, on which the Test service will be running

and the Backend Server Instance services.e2ebridge.com, on which the Exchange Rate Provider service is running.

5.2.3.4 Testing the Service

Now, the test service is ready to be compiled and run.

Page 155: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 155

Navigate to the deployment TestDeployment

of the service in the Model Compiler window

and select Run "TestDeployment" from the

context menu.

The service will be compiled, deployed to the

embedded server and started.

If no errors occur, ...

... click Open Test Case .

Page 156: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 156

Run the test case getExchangeRate without entering any values in the Request tab.

The Response tab opens. If the test case runs without any error, the gearwheel in front of the test case turns green .

Running the test case without an error means, that the service was reached, proceeded the request without errors and

returned information to the client.

As you did not fill in any values in the Request tab, the Exchange Rate Provider service returned the flag validRequest as

false and the exchangeRate as 0.

Switch back to the Request tab, enter the values USD and CHF as shown below and run the test case again.

Page 157: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 157

The Response tab shows the exchangeRate 1.0658 (or whatever exchange rate is actually provided) and the flag

validRequest is true, as this was a valid request of the Exchange Rate Provider service.

As you now know how to handle the Exchange Rate Provider service, you can continue with lesson 3 and import the

service into your lesson 3 model.

Save the UML model ExchangeRateProviderTest.

5.2.3.5 Importing the WSDL into the Lesson 3 Model

Switch back to lesson3.xml and start the importer again. This time, you will import the WSDL file directly into your lesson 3

model.

Select Import > Import WSDL / XSD File from

the E2E Compiler window again.

Page 158: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 158

Navigate to the location of the WSDL file and

select it.

Click OK.

Select the first option Import Into an Existing

Model. and click OK.

Page 159: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 159

Select the UML model of lesson 3 lesson3.xml

and click OK .

In the E2E Compiler Messages window, you can see wether the import was successful or not.

After a successful import, the imported service

should be part of the containment tree.

Now, the hard coding of the exchange rate in class CurrencyCalculator can be substituted by a call of the web service.

Page 160: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 160

Open the activity diagram Get Exchange Rate

of operation getExchangeRate.

Delete the activity node Define Exchange Rate.

Remember to use Ctrl - D when you delete the

node from the diagram pane, so that not only the

graphical representation of the activity is deleted

but also its definition.

Page 161: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 161

Select the operation getExchangeRate from the

imported web service definition of

ExchangeRateProvider.

Drag and drop in onto the diagram pane of Get

Exchange Rate.

All parameters of operation getExchangeRate are

shown as input respectively output pins.

Page 162: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 162

Rearrange the input pins to the left side of call

operation action, the output pins to the right side

of it.

Also, connect the call operation action to the

control flow.

Open the specification dialog of getExchangeRate

and assign the stereotype SOAPAdapter.

Page 163: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 163

Now the compiler needs to know where to fin the

SOAP operation.

In field Alias, select GetExchangeRate PortType

from the list.

Now, your activity diagram should look like this:

Page 164: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 164

Three parameters are still missing yet: fromCurrency, toCurrency and the flag validRequest.

name type direction

fromCurrency string in

toCurrency string in

validRequest boolean out

Create the three parameters or copy them

from the SOAP operation.

Place them on the diagram border as shown on

the left and connect them to their corresponding

pins.

Verify the direction of the automatically created

parameter nodes.

The SOAP operation call is implemented. Alternatively, you could have copied the operation call out of your test model

ExchangeRateProviderTest from diagram Test Services/GetExchangeRatePortType/

GetExchangeRatePortType/getExchangeRate.

Page 165: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 165

Save the UML model.

5.2.4 Implementing the Currency Conversion

The next step is to implement the behavior of the third action Calculate Total and Currencies. You will start with the

implementation of the currency conversion.

In the activity diagram Query Products, you now are going to create the activity diagram that defines the behavior of the

action. The new activity diagram will contain all activities to perform a currency calculation for each product record found in

the filtered XML data and to calculate a total of all product prices as shown in the picture below.

Page 166: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 166

Page 167: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 167

Right-click the action node Calculate Total and

Currencies and select New Diagram > Activity

Diagram from the context menu.

Page 168: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 168

The Create Diagram dialog window opens,

showing the containment tree.

Expand the package Data / Services /

QueryProductsService and select the port type

QueryProductsPortType. This is the destination,

where the new activity diagram will be stored.

In the text field Type Activity Diagram name type

in Calculations. This will be the name of the

activity diagram.

Click Create Owner and select Activity from the

list.

In the following activity specification dialog,

assign the name Calculations to the activity, too.

Close all dialog windows.

Page 169: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 169

The new activity diagram is opened in the

diagram pane.

Draw a initial node and assign the name Start.

Within this activity, you are going to iterate over all filteredProducts collected in the prior activities and process each

product. Before implementing this, you have to check wether any matching products where found at all within the filtering

activities. In the case that no product from file catalog.xml matched the entered keywords, the activity Calculations has to

return an empty result and no further calculations will be done.

Page 170: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 170

First, create an action below the activity start

and assign the name Create Output.

The output created will be of type SearchResult.

Draw a central buffer node next to action node

Create Output.

Click into the buffer node and type

searchResult : SearchResult.

This assigns the name searchResult and the type

SearchResult to the buffer node.

The searchResult will be buffered until it is

complemented within this activity.

Finish the definition by pressing Ctrl - Enter .

Page 171: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 171

Select the action node Create Output again and

press Ctrl - Enter to open the Action Script

Editor.

Create the object searchResult as shown in the

screenshot on the left.

Click OK or press Ctrl - Enter again to close the

Action Script Editor.

Now, define the required input parameter filteredProducts.

In the containment tree, copy the parameter

filteredProducts from Filter File Content to the

activity Calculations.

In the Specification dialog of filteredProducts,

set the direction of the parameter to in.

Page 172: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 172

Click Remove Arguments as you do not want to

create any additional activity parameter nodes.

Drag and drop filteredProducts on the diagram

border of Calculations.

You are going to check now, wether there is any input data to process.

Select the action node Create Output and

choose the control flow icon from the

smart manipulation bar.

Instead of left-clicking to position the action

node, click the right mouse button. Select

Decision/Merge from the context menu to

insert a decision node.

Page 173: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 173

Assign the name CheckEmpty and connect it to

the input parameter.

If the input parameter filteredProducts does not contain valid product information, the calculations will not be proceeded,

but the control flow will directly come to an end.

Below the buffer node insert an activity final

node and assign the name EndEmpty.

Page 174: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 174

Double-click the control flow coming from the

decision CheckEmpty and enter the name empty

in the specification dialog.

Insert else as a guard expression.

The effective guard expression will be added to the continuing control flow. Keep this in mind, as first you are now going to

reuse the previously copied operation from class CurrencyCalculator.

Drag and drop the operation getExchangeRate

from class CurrencyCalculator onto the

diagram pane.

This will draw the action node together with all

necessary input and output pins.

Rearrange the pins and draw a control flow from

CheckEmpty to getExchangeRate.

Page 175: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 175

Now remember to enter the guard expression on

this control flow. Select it and start typing the

name not empty.

As you are going to enter a complex guard

expression, press Ctrl - Enter to use the support

of the Action Script Editor and enter the following

expression:

filteredProducts.exists() and

filteredProducts.products.count() > 0

If the parameter filtered products is existing and

contains a number of products greater than 0,

this path of the decision will be followed.

Remember, that the else path has been defined

as to end in an activity final.

Your activity diagram now should look as follows.

Page 176: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 176

All product prices are in currency USD and are to be converted into CHF. Because of that fact, the exchange rate only has to

be get once and you are going to replace the input pins by value pins. A value pin is an input pin that provides a value to an

action that does not come from an incoming object flow edge.

Delete the input pins from the containment

tree with Del or from the diagram pane with

Ctr - D .

Select Value Pin from the Input Pin drop down

menu in the diagram toolbar.

Drag the value pin to the operation action

getExchangeRate and drop it there.

Page 177: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 177

Select Argument as you want to connect the

value pin to an operation argument.

Click OK.

Select parameter fromCurrency and click OK.

Page 178: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 178

Double-click the new value pin fromCurrency to

open the specification dialog.

In the Value field enter USD and click Close .

Page 179: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 179

The first parameter fromCurrency is replaced by

a value pin.

Create a second value pin in replacement of parameter toCurrency and assign the value CHF.

Page 180: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 180

After calling the SOAP adapter, you have to decide, whether you got a valid response from the Exchange Rate Provider.

Page 181: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 181

Insert a Decision Node and assign the name

CheckValid.

As an input, the decision node needs the flag

validRequest.

Draw the necessary object flow.

Page 182: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 182

When the SOAP request was not valid, you can

not continue with the calculations.

Draw an Activity Final named EndNotValid and

connect it to the decision node.

When the SOAP request was valid, you will

transfer the exchange rate to the output

parameters and continue with the calculations.

Draw a control flow that ends in an action node.

Page 183: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 183

Now, you have to define the guard expressions.

Double-click the control flow that leads down to

open the specification dialog.

Assign the name is valid and enter the guard

expression validRequest.

Click Close .

Note: As it concerns a variable of type boolean, the expression validRequest is identically equal to the expression

validRequest = true.

Double-click the other control flow which leads

to EndNotValid.

Assign the name is not valid and enter the

guard expression else.

Click Close .

If the request of the external SOAP service was valid, the calculations are proceeded. If not, all further calculations are

skipped.

Page 184: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 184

Now, continue with the calculations.

To the unnamed action node assign the name Move Exchange Rate to Output.

Page 185: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 185

As the exchange rate will be moved to output,

you need the exchange rate as an input to the

action node.

Draw the appropriate object flow.

The object searchResult will be used within this action node and is therefore needed as an input. To avoid crossing control

and object flows which reduce comprehensibility of the diagram, you will not directly connect the buffer node searchResult

created in Creating Output to the action node Move Exchange Rate to Output.

You are going to draw a second buffer node searchResult near the right diagram border on the left of action node Move

Exchange Rate to Output.

But first, make some room in your diagram. Press F11 to switch to full screen mode.

Page 186: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 186

The MagicDraw menu bar disappears, the containment tree and the Compiler window are toggled to auto-hide mode to the

benefit of the diagram pane, which expands to the full screen.

Select all diagram elements beside the

parameter filteredProducts by drawing a

selection area.

All selected elements are marked with black

rectangles.

Page 187: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 187

Move the selection a little to the left.

If you drag the selection area over the diagram

border, the diagram border will move

accordingly.

Close Full Screen mode by clicking the

appropriate button in the upper left corner or by

pressing F11 again.

Draw a buffer node next to the action Move

Exchange Rate to Output.

Click into the buffer node to assign a name and

start typing se. A suggestion list pops up and

shows all objects that are available within the

activity.

Select searchResult from this list.

Note: As buffer nodes are only the

graphical representation of an object, it

does not pose a problem to draw a buffer

node twice in the same diagram.

Connect the buffer node to the action node.

Page 188: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 188

Select the action node Move Exchange Rate to

Output again and press Ctrl - Enter to open the

Action Script Editor.

Enter the statement shown in the screenshot on

the left.

The value of the output parameter exchangeRate

CHFUSD is copied to the attribute exchangeRate

of the object searchResult.

Close the dialog.

The action node is completed.

Save the UML model.

Page 189: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 189

In the next step, the price conversion from USD to CHF is done for each product record found in the filtered data. The

filtered products are stored in object filteredProducts, which you need as an input parameter. You will define an UML

iteration to iterate each product record and execute specific actions.

E2E Builder provides functionality to iterate over action script, an adapter, a class operation or over a call behavior action.

In this lesson, you will learn how to iterate over an action script as shown in the picture below.

Iterations are defined by the use of expansion regions with stereotype <<iterative>>.

Select an Expansion Region from the diagram

toolbar and place it on the diagram pane.

The expansion region is drawn with an

Expansion Node in the upper left corner (

).

An object flow that arrives at an expansion

node contains a collection of objects or data,

which are separated by the expansion node

before being passed onto elements within the

expansion region. An expansion region must

have one or more expansion nodes receiving

input and may have any number of expansion

nodes as output including the case of having no

output expansion node.

Page 190: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 190

Scroll down if necessary and resize the

expansion region. Toggling to Full Screen mode

may be helpful as well.

Connect the expansion region to the control flow.

If resizing is not possible, turn off Autosize mode

in the expansion region's context menu.

Page 191: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 191

Draw the object flow from the activity

parameter node to the expansion node as

shown in the picture on the left.

Open the Expansion Node's specification dialog

and assign the name product and the type

Product.

The element product is used as a temporary

iteration object. In each iteration, a product record

is stored in this object.

Click Close .

Page 192: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 192

The object filteredProducts of type Catalog has an

array attribute products that contains elements of

type Product.

In each iteration, one element of the array

products will be assigned to the temporary

iteration object product.

In order to pass an element of the array products of filteredProducts to the iteration object product, you can use a

Transformation.

Right-click the object flow connecting the

activity parameter node with the expansion

node and select Transformation from the

context menu.

Page 193: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 193

This stereotypes the object flow as

transformation and adds the corresponding icon

.

Double-click this icon to open the specification

dialog of the Transformation.

In the Select field, enter

filteredProducts.products and close the

dialog.

To avoid typing errors, you could also use the

Action Script Editor for this.

Page 194: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 194

The transformation rule is displayed in the

diagram.

Now, define the result of each iteration step.

Create an Output Expansion Node by

selecting the corresponding icon from the

smart manipulation toolbar of the expansion

region.

Page 195: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 195

Drag the output expansion node to the bottom

of the expansion region.

Each expansion region may have only one input

expansion node, but several output expansion

nodes.

The calculated price in CHF is no attribute of

class Product, as Product describes the

structure of the XML file.

For storing the price in CHF, you defined the

class ProductExtended with all attributes of

Product and the additional attribute priceCHF.

This type, you are going to use for the output

expansion node.

Open the specification dialog of the output

expansion node.

Assign the name extendedProduct and the type

ProductExtended.

Click Close .

Page 196: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 196

The result of each iteration step has to be

stored in an array.

Draw an object flow starting at the output

expansion node and ending in a central buffer

node.

Assign the name extendedProducts.

Open the specification dialog of

extendedProducts.

Apply the stereotype <<E2EArray>> and assign

the type Array.

The array element type is defined in field Array

Element. Each array element has to be of type

ProductExtended. Select the corresponding type

from the list.

Click Close .

Now, you have got defined the input and the output of the expansion region. The purpose of this iteration is to iterate over

an action, which calculates the CHF price for each products item.

To add an action node to the expansion region,

select the Action icon from the diagram toolbar

and place it within the expansion region.

Assign the name Calculate CHF Prices.

Page 197: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 197

The action node Calculate CHF Prices needs the

exchange rate as input to do the calculation.

Therefore, draw an object flow from the output

pin exchangeRateCHFUSD of getExchangeRate

directly to the action node Calculate CHF Prices.

Connect the input and output expansion nodes to

the action node as well.

This action will contain the action script being processed for each array element of the input array. As a result of each

iteration step, a new item will be appended to the output array.

Within the action script, the array items have the attribute name defined in the input expansion node. The expansion node

creates temporary input array items.

The output objects need to be created by create statements within the action script and are appended to the related

output array by the output expansion node.

Page 198: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 198

Select Calculate CHF Prices and open the

Action Script editor.

First, create object extendedProduct, that you

need to store the calculated data.

Move all product data from the input object

product to the output object productExtended,

using set statements.

set extendedProduct.category = product.category;

set extendedProduct.link = product.link;

set extendedProduct.manufacturer = product.manufacturer;

set extendedProduct.priceUSD = product.priceUSD;

set extendedProduct.seller = product.seller;

set extendedProduct.title = product.title;

set extendedProduct.type = product.type;

Finally, your are going to implement the calculation of the CHF price. You will use the class operation calculatePrice you

defined in class CurrencyCaluclator.

Remember, that you made it available to be used within action script via a <<use>> dependency called

useCurrencyCalculator.

Page 199: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 199

Start typing the set-statement set

extendedProduct.priceCHF = and press

Ctrl - Space to display the suggestion list.

Select the <<use>> dependency

useCurrencyCalculator.

Type : and the available methods will be

displayed in the suggestion list.

Select calculatePrice.

Enter the two needed parameters

product.priceUSD and

exchangeRateCHFUSD within the brackets.

Page 200: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 200

Finalize the statement by typing if

product.priceUSD.exists(); as the

currency calculation only should be executed if a

price is assigned to the product.

The last statement in total should read:

set extendedProduct.priceCHF =

useCurrencyCalculator:calculatePrice(product.priceUSD,exchangeRateCHFUSD) if

product.priceUSD.exists();

Save the UML model.

5.2.5 Implementing Additional Calculations

In the last step, you are going to summarize the prices to form a price total and calculate the delivery charge, assuming a

order quantity of one.

This additional information you defined to be

stored in class SearchResult.

Objects of class SearchResult also contain zero

to infinite objects of class ProductExtended in

array matchingProducts defined on the

association end.

As an output of the iteration you implemented in

the last chapter, you got the array

extendedProducts containing objects of type

ProductsExtended.

All filtered products with converted prices are

stored in this array.

Now you are going to set this array into the output

object.

Page 201: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 201

Below Calculate CHF Prices draw an action node

Set Matching Products in Output and connect it to

the control flow.

Before calculating the prices, you already defined

a buffer node searchResult of type SearchResult

and stored the exchangeRate in this object. You

could connect this buffer node to Set Matching

Products in Output now, but for reasons of

comprehensibility, draw a third buffer node

searchResult near the right diagram border.

Assigning a name, type s and select searchResult

from the suggestion list.

Connect the objects to the action node.

Open the Action Script Editor of Set Matching

Products to Output and enter the following

statement:

set searchResult.matchingProducts =

extendedProducts;

The array matchingProducts you defined in the

class diagram on the association end belonging to

class SearchResult receives the content of array

extendedProducts, containing all filtered products

with converted prices.

Click OK.

Page 202: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 202

Draw an action node with action flow below

Set Matching Products in Output and assign

the name Calculate Sums.

Draw an object flow from searchResult to the

newly created action node, as you need it as

input.

set searchResult.totalAmountCHF = reduce

searchResult.matchingProducts

using element.priceCHF + nextElement.priceCHF if

single use element.priceCHF;

set searchResult.totalAmountUSD = reduce

searchResult.matchingProducts

using element.priceUSD + nextElement.priceUSD if

single use element.priceUSD;

Open the Action Script editor and insert the two

set statements as shown on the left.

Page 203: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 203

In this action script, you combine a set statement with a reduce operation. The reduce operation applies to arrays and

allows you to reduce the array having elements of complex types to a scalar value. Therefore, an expression is recursively

applied to each array element (element) and its next element (nextElement).

set searchResult.totalAmountCHF

The total of the reduce operation is stored in searchResult.

totalAmountCHF.

reduce

searchResult.matchingProducts

The reduce operation is applied to the array searchResult.

matchingProducts.

using element.priceCHF +

nextElement.priceCHF

For calculating the sum, you must use the currently evaluated array

element (element) and its next neighbor (nextElement).

The attribute priceCHF of element and nextElement are added up and the

result is stored in searchResult. totalAmountCHF.

if single use element.priceCHF;

This is a mandatory extension and allows to define the action for an array

containing only one single element.

If there is only one matching product, the total amount equals to the price of

this product.

For more information about the reduce operation refer to the E2E Bridge Reference Guide.

Finally, you are going to calculate the delivery charge.

Page 204: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 204

Draw an action node with action flow below

Calculate Sums and assign the name

Calculate Delivery Charge.

Draw an object flow from searchResult to the

newly created action node, as you need it as

input.

local noChargeAmount = setting("No charge at amount

of", 50.0);

local deliveryCharge = setting("Delivery charge",

10.0);

set searchResult.deliveryCharge = if

searchResult.totalAmountCHF >= noChargeAmount

then 0.0

else deliveryCharge;

Open the Action Script editor and insert the

statements as shown on the left.

For the delivery charge calculations, you need the delivery charge amount itself (deliveryCharge), the amount starting from

which the delivery is free (noChargeAmount) and the total of the order you just calculated (searchResult.totalAmountCHF).

local noChargeAmount = setting("No charge at amount

of", 50.0);

local deliveryCharge = setting("Delivery charge",

10.0);

noChargeAmount and deliveryCharge are

defined as local variables within the action

script.

Remember that in lesson 2 you already learned how to use the setting macro function. With the setting macro literals can

be stored global to a Composite service. In the Bridge context, it is possible to define name / value pairs that are

configurable from the E2E Embedded Runtime and the E2E Console.

The setting macro function also can be combined with a local variable definition.

set searchResult.deliveryCharge =

The result of the calculation is stored in searchResult.deliveryCharge.

if searchResult.totalAmountCHF >=

noChargeAmount

The set statement can be combined with a condition.

If the order value exceeds the limit defined in noChargeAmount ...

then 0.0

... then no delivery charge is asked ...

Remember to use the format 0.0 as searchResult.deliveryCharge is of

type float.

else deliveryCharge; ... in all other cases the delivery charge defined by the setting is assigned.

Page 205: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 205

Complete the diagram by drawing the activity final node and searchResult as output parameter.

Assign the name End to the activity final node.

Page 206: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 206

Copy the parameter searchResult from

QueryProducts to Calculations.

Drag and drop the copied parameter searchResult

onto the left diagram border and connect it to

Calculate Delivery Charge.

Now, all calculations are implemented.

Save the UML model.

Page 207: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 207

5.2.6 Finalizing the Activity Diagram Query Products

Switch back to activity diagram Query Products.

In the previous step you defined output parameter searchResult of activity diagram Calculations. This parameter was

automatically added to the activity node as a pin.

Page 208: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 208

Right-click Calculate Total and Currencies and

select Related Elements > Display Pins.

A list of all pins pops up. Deselect the input pin

filteredProducts as it is not needed here.

Click OK.

Page 209: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 209

Move the output pin searchResult to the lower

right corner of the action node and draw an object

flow to the action node Set Title, which needs

searchResult as an input.

The package GetProductService is not needed

anymore and can be deleted.

Leaving the package would lead to compiler

errors as you changed the interface of the

CurrencyCalculator in the second iteration.

Page 210: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 210

Save the UML model.

Page 211: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 211

5.3 Component and Deployment Diagrams

In the picture below, the component diagram, which results from the first iteration, is displayed. You now are going to

insert a SOAP Adapter to access the E2E Exchange Rate Converter.

After running the E2E Components Wizard, the component diagram will look like shown in the following picture.

Page 212: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 212

The deployment diagram will be extended, too, as the deployment for the ExchangeRateProvider backend has to be

defined. An artifact of this service is running on services.e2ebridge.com, which will be defined as an additional backend

server.

After extending the deployment diagram with the E2E Deployment Wizard, the diagram will look like shown below.

5.3.1 Reworking and Extending the Component Diagram

For extending the existing configuration you created in lesson 2, you will use the Components Wizard to define a file

backend. But first, you will do some renaming.

Open the component diagram EducationComponents.

Click the icon Edit Component Diagram

from the diagram toolbar to start the

Components Wizard. Do not use the icon E2E

Components Wizard in the MagicDraw menu

bar, as this would create a new component

diagram.

The E2E Components Wizard dialog window opens.

Page 213: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 213

Select the node Backends in the tree on the

left.

Select the GetExchangeRate

ServiceComponentArtifact from the list of

available artifacts.

Click > to use it as a backend service.

FileSystemService and GetExchangeRateService

are used as backend services.

Click Skip as you are not going to define any

further backends.

Page 214: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 214

Click OK to go on with creating the dependency

between the Composite service and the newly

defined backend.

Ending point of the dependency is the backend

interface artifact GetExchangeRatePort

TypArtifact. Select it from the list Point

Dependency to on the left and click the button > .

Page 215: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 215

The alias GetExchangeRatePort Typ was provided

by the imported service ExchangeRateProvider.

Click OK.

Now, two backend dependencies are defined: one

to use the file system backend and one to use the

SOAP backend.

Click Next .

Page 216: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 216

Confirm drawing the component diagram by

clicking Finish .

Click Yes to refresh the deployment data and

save the UML model.

The generated component diagram will open.

At the backend side, the backend service artifact GetExchangeRateServiceComponentArtifact has been created together

with its interface artifact. The dependency from Service artifact EducationLesson3 to the file interface artifact displays the

tagged value alias with the assigned value GetExchangeRatePortType.

Remember that you can re-arrange the paths by clicking Route Paths Orthogonal Style from the Quick Diagram Layout

function.

Page 217: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 217

The compiler complains about a missing backend service in the deployment diagram. This is correct. You are going to

extend the deployment diagram with the deployment wizard in the next step.

Page 218: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 218

5.3.2 Extending the Deployment Diagram

The deployment diagram contains a Bridge Server and a File System artifact, both on localhost. The E2E Exchange Rate

Provider service is located on services.e2ebridge.com. This is why you need to define another node instance.

For extending the existing deployment, you will use the Deployment Wizard.

Open the deployment diagram

EducationDeployment and click the icon

Edit Deployment Diagram from the diagram

toolbar to start the Deployment Wizard.

Do not use the icon E2E Deployment Wizard in

the MagicDraw menu bar, as this would create

a new deployment diagram.

The E2E Deployment Wizard dialog window opens.

Page 219: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 219

The wizards asks to select a configuration

artifact. As this is already done and the name of

the deployment diagram cannot be changed,

click Next .

In the tree panel of the wizard, the tree node

Backend Server is displayed. If you expand this

tree node, you will find the backend node

instance FileSystemServiceArtifact, which is

located on backend server instance localhost.

The imported service ExchangeRateProvider

provided you with a backend definition. Select

services.e2ebridge.com and click > .

All backend servers are displayed on the right

side of the customization panel.

Select the backend node services.e2ebridge.com

in the tree on the left.

Note the artifact instance of

GetExchangeRateServiceComponent, which was

provided by the exchange rate provider service.

Click Next .

Page 220: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 220

This is the final step of the Deployment Wizard.

You need to confirm drawing the deployment

diagram.

Click Finish .

As of changing the deployment diagram, some

data needs to be reloaded by the Model Compiler.

Click Yes to refresh the deployment data and

save the UML model.

The deployment diagram will be re-drawn in MagicDraw. The defined node and artifact instances are saved in the package

Data / File View.

The generated deployment diagram will open.

Page 221: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 221

Now, the Composite Service EducationLesson3 can be compiled.

Page 222: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 222

5.4 Compilation

The UML model has been completed now. You do not have to do further changes in the deployment diagram or on the port

type definitions because you have finished that part already in the first iteration. You are ready to compile and to deploy the

UML model, to test it with the Model Debugger, and to use the Web Service with the Excel client.

Compile the Composite Service's deployment EducationDeployment. No errors or warnings should be reported anymore.

Page 223: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 223

5.5 Solving Errors

If no error has been reported, skip this chapter.

If you cannot fix the problem, open the Builder

project E2E Education (default location

C:\E2EBridgeDocumentation_5\

pdf\E2EBuilderProjects).

Click OK .

If you not have opened this project before, the

E2E Builder File Chooser pops up. Select the file

lesson3.xml in sub folder uml, which contains all

reference models of the first iteration.

If you already studied the solution models in lesson1 or 2, the builder will automatically open the model file last used.

Page 224: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 224

Close the open project. Switch to the File View

tab of the Model Compiler and double-click the

file lesson3.xml to open it.

You can compare the solution model with your model to find the error. Remember, that you can switch between open

project files using the Opened Projects toolbar of Magic Draw.

Note: By loading lesson3.xml from Builder Project E2E Education your own project Education is no longer the active

Builder project, though your own XMI file lesson3.xml is held open within Magic Draw. Wanting to continue working

with Education, you will have to reopen the project.

See chapter Solving Errors in the lesson 1 or 2 document to get further information on how to change the active Builder

project..

As an alternative, you can continue your studies with the solution model by importing the solution into your own Builder

project.

Compile the imported model and continue with lesson 3.

See chapter Solving Errors in the lesson 1 or 2 document to get further information on how to import an xml document into

your active Builder project.

Page 225: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 225

5.6 Testing with E2E SOAP Test Tool

Now, you can test the completed service with the E2E SOAP Test Tool.

Start the service with Run "Education

Deployment" in the Compiler window.

The service starts up.

Open the E2E SOAP Test Tool by clicking Open Test Case . The SOAP Test Tool window opens and shows a test case for

lesson3.EducationLesson3.EducationDeployment.

Page 226: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 226

Create the input parameter userInput.

Enter a title into the parameter title and add an item to the keyword array.

Append an array element for each keyword you wish to enter and type in some values.

Page 227: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 227

Run the test case.

On the Response tab, expand the tree. The rows shown in the picture below will be selected if you used the keywords

Pirates and Nemo on the Request tab.

The SOAP request of the external web service ExchangeRateProvider returned an exchange rate of 1.0658. On each

product record the price in CHF was calculated according to this exchange rate. Assuming an order quantity of 1, the total

amounts in USD and CHF were calculated. As the total amount in CHF totalamoutCHF is 38.34 CHF and therefore less than

50 CHF, a delivery charge of 10 CHF was determined.

Page 228: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 228

5.6.1 Requesting the Web Service with the Excel Client

Open the Excel spreadsheet Client-lesson3.xls, which is provided with the E2E Bridge software.

You will find the Excel spreadsheet in the documentation location (default location:

C:\E2EBridgeDocumentation_5\Documentation\pdf\E2E Education\Lesson3). Double-click the file to start the Excel

application.

Be sure to enable the macro content of this

spreadsheet.

In the picture below, you find the Excel spreadsheet that is used to display the search results returned by the Web Service.

5.6.1.1 Output

The following fields are needed to display the output data in the Excel spreadsheet:

Title

Category

Manufacturer

Price USD

Price CHF

Seller

Page 229: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 229

Seller type

Link

Exchange (the same exchange rate is used for all data rows)

In addition, the following output data is displayed above the data table:

Title

Total amount CHF

Total amount USD

Delivery charge

5.6.1.2 Input

The following input data is sent to the Web Service.

Tab Preferences:

Title

Note that the E2E Composite Service URL must

be correct as otherwise the service can not be

accessed. If you used other service names or a

different port number, you have to change it

here.

If your are not sure about the correct service

path, you can compare respectively copy it

from the test case properties.

Tab Search Parameters:

Keywords

Page 230: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 230

5.6.1.3 Requesting the Web Service

Enter a title and switch to tab Search

Parameters.

Enter some search keywords and click >>

Search << .

The excel spreadsheet is displayed with the retrieved product information.

Page 231: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 231

Page 232: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 232

6 Testing with E2E Analyzer

Remember that E2E Analyzer is the interface to the trace feature, with whom you can test all operations on the fly. It traces

the execution path of a service that is run through the test. You may view this path graphically, e.g. in order to debug web

services or verify their correct functioning. Each operation defined on a port type can be tested with this tool. It makes no

difference wether the service is running in the E2E Embedded Runtime or has been deployed to a server.

For detailed information see the E2E Builder User Guide.

Page 233: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 233

6.1 Starting the Service and the Analyzer

Start the education service of lesson 3 in the

Embedded Runtime and start the E2E Analyzer.

As you have used the Analyzer before with lesson2, E2E Builder Project Education reopens automatically.

Expand the tree of the lesson3 deployment lesson3.EducationLesson3.EducationDepoyment.

Page 234: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 234

You can see the request and response log from the earlier running of the test case with the E2E SOAP Test Tool.

Page 235: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 235

6.2 Test Case Properties

Click the test case queryProducts.

In the left panel of the Analyzer window an additional tab UML appears, saying "The trace is disabled for this test case.".

This is correct as this test case has been created with the E2E SOAP Test Tool which does not support tracing.

Select Properties from the test case's context

menu.

Page 236: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 236

Switch to the Trace tab, enable trace and check

the option Full Trace.

Click OK.

Run the test case again to collect the trace

information.

Page 237: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 237

6.3 Tracing through the Service

Switch to the UML tab.

You can see the Query Products service reading the XML file and calling the external web service on

services.e2ebridge.com. Trace through the UML model. If the output object contains an array, the list of array elements can

be visualized in the Watches panel by right-clicking the messages.

Page 238: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 238

Clickingk the operation name queryProducts in

the main diagram (tab Main), the new tab

queryProducts will be displayed (see bottom of

the window). It shows the activity diagram

Query Products, which is assigned to the

selected operation.

Click action node Read XML File.

Page 239: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 239

The behavior of this action, the activity diagram

Read XML File, is displayed. Click the object data.

The object will be added to the Watches list.

Double-clicking the object data in the watches

panel or selecting Show Value from the context

menu will open the E2E Blob Viewer showing the

complete content of the blob.

The Blob Viewer shows the blob in hexadecimal

encoding.

Click .

Page 240: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 240

The Blob Viewer shows the decoded blob so that

the content of the XML file is viewable in plain text.

Switch back to the tab queryProducts and navigate through Filter File Content to Create Keywords Pattern.

Note the branch, which was followed according the evaluated expression in the decision node.

Page 241: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 241

Clicking on the term branching expression

displays the branching expression.

On the right side of the decision, you can see 1

unfollowed branch. Clicking it and the branching

expression is displayed.

If there is more than one unfollowed branch

(which is possible as well), a box with a list of all

not followed branches is displayed. By clicking e.g.

expression1 the not matching expression is

displayed.

You can run a second test case with other parameters.

Page 242: E2E Bridge Education Lesson 3

Education Lesson 3

© 2012 E2E Technologies | www.e2ebridge.com | 242

Select queryProducts from the left tree and

create a second test case.

Create userInput.

Enter a title and no keywords and run the test

case.

Switch to the UML tab and navigate to Create Keywords Pattern. Note, that now the branching expression and the control

flow differs from the previous test case.