Skip to main content

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

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

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

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

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

All information submitted is secure.

  • Close [x]

Deriving Web services from UML models, Part 4: Defining Web services

Establish the interfaces between your Web services and the outside world

Scott W. Ambler, Prectice Leader, Agile Development, Rational Methods Group, IBM
Scott W. Ambler is a Practice Leader for Agile Development within the IBM Methods group. He develops process materials, speaks at conferences, and works with IBM clients worldwide to help improve their software processes. Scott is author of several books, listed on his Web site at www.ambysoft.com. Scott is also a recognized Ratonal Thought Leader, whose homepage may be viewed here.

Summary:  Web services can be offered by cohesive collections of classes called domain packages in such a way as to provide significant functionality through a small number of services. In the final installment of this series, Scott W. Ambler shows you how to complete the transformation of your object-oriented application into a suite of Web services.

Date:  01 Jun 2002
Level:  Introductory
Also available in:   Japanese

Activity:  2838 views
Comments:  

In the previous tip in this series, you learned how to identify the domain packages within the object-oriented application design for SWA Online, an online storefront that enables customers to place orders and have them shipped to their homes (see Resources). The next and final steps in this process are to identify domain package contracts and then to define the Web services interfaces.

Step 5: Define domain-package contracts

Domain-package contracts are those class contracts that are accessed by classes outside of a domain package. (Class contracts that are only used by classes within the subsystem are not domain-package contracts.) For example, the contracts for the Item package in Figure 1 would be the combination of the class contracts of the Item, ShippingContainer, and ShippingRestriction classes, because they were accessed from classes outside of the package. (Figure 1 and all other examples in this series are drawn from your SWA Online example.) Because ContainerType instances only collaborate with ShippingContainer objects, the class contracts of ContainerType can be ignored. As you would expect, the domain-package contracts form the collection of Web services that can potentially be provided by a package.


Figure 1. A package diagram for SWA Online
A package diagram for SWA Online

Were you to just combine the class contracts of the classes depicted in detail in Figure 2, you would have the following list:

  • reorder()
  • reserveItems()
  • getPrice()
  • getRestrictions()
  • getContainer()
  • getFullDescription()
  • getVolume()

This list is interesting, but you should see if you can pare it down in order to reduce the number of Web services that you will eventually offer. To do this, let's examine why some of the contracts are invoked. For example, the contract getContainer() is invoked so that getVolume() can later be invoked by the Shipment class, presumably to determine shipping cost and packing requirements. Therefore, these two contracts could be combined, likely into a getShippingContainer() contract that would return an XML structure (more on this in a bit); they could perhaps even be rolled up into a getItem() contract that returns an XML structure containing all relevant item data. Similarly, getPrice(), getRestrictions(), and getFullDescription() could also be rolled up into getItem().

Here's the new, simplified list of contracts:

  • reorder()
  • reserveItems()
  • getItem()

It's important to make sure that contracts of a package are cohesive -- that is, that it makes sense to put them together. If the contracts do not make sense as a group, then you should distribute them among multiple packages. If your initial contracts for the Order component include fufillOrder(), addItem(), removeItem(), and orderLunchForExecutives(), you likely have a problem, because the lunch ordering contract doesn't fit well with the others.


Figure 2. The Item classes
The Item classes

Step 6: Define Web service signatures

What should the signatures be for the three Web services supported by the Item package? First, you know that they'll return XML structures, because that's the way that Web services work. You'll need to design those structures (see Resources for more information) to return the information that you require. In the case of getItem(), you would need to include basic information such as the item price, description, and number, as well as container information and any shipping restrictions.

Second, you need to identify the parameters passed to the Web services as well as the return values from them. To identify these parameters, you need to ask yourself what minimal information is required to fulfill the purpose of the Web service. For example, to reoder an item, you would need to identify which item you want to reorder and the number to reorder. Similarly, to identify the return value, you need to ask yourself what information the Web service should provide to the invoker. In the case of reordering, the invoker of that service would want to know whether the item was successfully reordered. For this case, the signatures are:

  • reorder(int itemNumber, int orderAmount): ReturnStatusXML
  • reserveItems(int itemNumber, int orderAmount, int orderNumber) : ReturnStatusXML
  • getItem(int itemNumber) : ItemXML

A fundamental concept to remember is: At this point, you are no longer modeling objects; you're modeling functions. Thus, you need to pass such basic information as identifiers -- itemNumber and orderNumber, for example -- as parameters, so the Web service will act on the right objects within your system.


Discover your applications' Web services potential

In The Unified Modeling Language User Guide (see Resources), Grady Booch, Ivar Jacobson, and James Rumbaugh, known as "The Three Amigos," suggest that you "manage the seams in your system" by defining the major interfaces for your components and packages. What they mean by this is that you want to define the interfaces -- in this case, the collection of Web services supported by each package -- early in the design process. That way, you are free to work on the internals of each package without having to worry about how you will affect other development efforts -- you just have to keep the defined interface stable.

This series of four articles presented a process, based on the techniques presented in Designing Object-Oriented Software and expanded upon in Building Object Applications That Work (see Resources for links to both) for refactoring a traditional object design for the purposes of deploying it to a distributed environment. To illustrate this process, you worked through the SWA Online case study, a simplistic e-commerce system whose initial high-level class diagram is depicted in Figure 3. By doing so, you discovered how to focus on the critical aspects of your design that were pertinent to identifying Web services. You also saw how to organize your design into domain packages, and then how to keep the number of Web services provided by your system to a minimum.

You can see how far we came by looking at the initial class model for SWA Online in Figure 3. Now you should be able to use the techniques outlined in this series to build your own Web services out of your existing object-oriented applications and models.


Figure 3. Initial class model for SWA Online
Initial class model for SWA Online

Resources

About the author

Scott W. Ambler is a Practice Leader for Agile Development within the IBM Methods group. He develops process materials, speaks at conferences, and works with IBM clients worldwide to help improve their software processes. Scott is author of several books, listed on his Web site at www.ambysoft.com. Scott is also a recognized Ratonal Thought Leader, whose homepage may be viewed here.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

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

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

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

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

(Must be between 3 – 31 characters.)

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

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=11669
ArticleTitle=Deriving Web services from UML models, Part 4: Defining Web services
publish-date=06012002
author1-email=scott_ambler@ca.ibm.com
author1-email-cc=

Next steps from IBM

Rational Modeler is a free, UML 2.1 based environment that helps users to improve communication by specifying, visualizing and documenting their system, architecture and software designs using a standard graphical language.


Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers