<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Modeling Services using Contracts</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Thibault Estier</string-name>
          <email>thibault.estier@unil.ch</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Beat Michel</string-name>
          <email>michel@beatmichel.ch</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oliver Reinhard</string-name>
          <email>oliver.reinhard@paranor.ch</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Beat Michel Conseil en Informatique 1030 Bussigny</institution>
          ,
          <country country="CH">Switzerland</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>HEC - Universit ́e de Lausanne 1015 Lausanne</institution>
          ,
          <country country="CH">Switzerland</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Paranor AG 3046 Wahlendorf</institution>
          ,
          <country country="CH">Switzerland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Design by contract is a well-established paradigm in software engineering. Bertrand Meyer first introduced the rigorous distinction between the responsibilities of service provider and service consumer for fine grain software artifacts (classes). This paper considers service contracts in the context of service-oriented architecture for complex enterprise information infrastructures. Identifying dependencies between applications with service contracts may help to master the complexity of numerous interconnected information systems and to ease evolution towards a service-oriented architecture. This paper proposes both a model and a methodology to systematically apply the notion of contract for structuring relationships and identifying dependencies between applications in a service oriented architecture.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        While enterprise-wide IT infrastructures face every day more complex challenges in
managing and developing application interoperability, Service-Oriented Architectures
(SOA) 4 gain progressively more and more success as an integrative paradigm.
Reasoning about applications interfaces in terms of services seems a natural extrapolation
of software engineering concepts for components assembly: a software component, or
module, should expose a clearly defined set of operations and properties, should give
strict conditions of usage, without exposing the details of how the component executes
these operations. Decomposing software into modules was already introduced in 1972
by D. Parnas [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        A clear separation between the purpose of a component (what) and its actual
implementation (how) gives interesting properties (reusability of the component, low
coupling between a component and its users, etc.). These are also desirable properties of
4 While it is difficult to trace a unique origin of the term SOA, it seems to have appeared
around 2000 in both IBM research papers and Gartner group reports, before being fixed by
standards [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
related applications in an IT infrastructure. This naturally promoted the idea of
unambiguous interface definitions for information exchanges between applications. The SOA
approach encourages the definition of exposed properties and operations available
outside an application to be defined in terms of services. While this idea already appeared
in distributed applications and with middleware buses (like DCOM or CORBA for
instance), the recent apparition and success of web-oriented standards for information
interchanges refuelled it (Web Services and XML encoding of information).
Unfortunately it is generally difficult to handle an enterprise application as a “large software
component”: the definition of an appropriate and reusable interface for a large
application is generally a complex task. The model proposed in this paper helps to better
express the offered services of an application, by providing a complete and rigorous
specification of each service.
      </p>
      <p>
        Bertrand Meyer introduced in 1992 [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] the notion of Design by Contract to help
formalizing the exposed behaviour of a software component, in terms of pre-conditions,
post-conditions and invariants. One of the extensions of a service description proposed
here includes definitions of pre- and post-conditions for each operations offered in a
service. So we take the word contract for a service in a similar meaning, rather than
the emphasis on legal involvement of both parties.
      </p>
      <p>In this paper, we recognize the importance of web services for handling
applications interoperability between organisations or in heterogenous contexts, but we focus
on integration inside a given IT infrastructure (Enterprise Applications Integration),
possibly but not necessarily implemented using web services. In the global map of an
IT infrastructure, applications may offer services based on very different protocols and
mechanisms, including traditional file transfers, publish/subscribe systems, etc. We
propose a service description independent of the underlying mechanism used to make
the service accessible. This description gives also important information about failures,
failure signals, how they will propagate and when they may arise.</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        Heckel &amp; Lohmann recently proposed [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] to also adopt pre- and post-conditions for
extending Web Services definitions. The behaviour of service operations is then given
by UML collaboration diagrams transformation rules. Their proposition is to use these
graphs for automatic testing of a web service.
      </p>
      <p>
        Tosic, Pagurek and Patel [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] proposed a language called Web Service Offerings
Language (WSOL), to extend a WSDL description with formal expressions of
various constraints, including pre- and post-conditions, plus a notion of future-conditions.
The language enables declaration of several business deployment characteristics of a
service (like Quality of Service or Service Level Agreement). These definitions are
oriented toward management, monitoring and measurement of deployed services, when
the usage of a service available in a different organization implies some garanties for
the application willing to use it.
      </p>
      <p>
        In the domain of Web Services, several XML-based language extending WSDL
[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] have been proposed: WSLA (Web Services Level Agreements) from IBM [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], and
WSML (Web Service Management Language) coming from a proposition by HP [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
Both propositions are also focused on web services and on formalization of service–level
agreements.
      </p>
      <p>In the second section of this paper, we propose and illustrate a complete concept of
Service Contract, covering typical questions that a designer must handle when defining
a service: orientation, scope, structure, semantics and quality. The third section sketches
briefly a methodology applicable to migrating a traditional infrastructure to a
serviceoriented architecture, using systematically this service modeling approach.
2</p>
      <sec id="sec-2-1">
        <title>Service Model and Service Contracts</title>
        <p>A service contract is a mutual agreement between the provider of a service and the
consumer (or consumers) of the service. Like a legal contract, a service contract defines
the conditions and terms under which the provider and the consumers will collaborate.
A service contract can be expressed using a service model. The model defines the
orientation and type of dependencies which exist between parties, and defines four
aspects of each service:
1. Operations and Structures – the service operations, their parameters and
parameter types,
2. Semantics and Scope – the behavior of the service operations, returned results
and side effects; do they overlap the information scope of other services,
3. Failures – when the consumer-provider interaction will not succeed,
4. Quality – what non-functional requirements does the service comply to.
While the service model defines the interaction between providers and consumers, an
actual service contract based on the model identifies the actual provider and consumer(s)
and is only established at deployment time or even at run time.</p>
        <p>Quality of service, is also an important aspect of a service model, however, it is not
the focus of this paper and is not further addressed. The other aspects are presented
as sub-sections of this section.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Example illustrating the model presentation</title>
      <p>We illustrate the various aspects of the model using an example: a DVD-rental business
with an inventory of movies and carries zero or more DVD copies of each movie. The
corresponding IT architecture consists of a server-based DVD-rental application and
two types of user-interface clients: the internet-based home client supports customers
reservation request; the staff client at the store is for reservation, rental and customer
management by the staff.</p>
    </sec>
    <sec id="sec-4">
      <title>Orientation – Establishing a service relation</title>
      <p>The relationship between service provider and consumers is asymetric: consumers
applications depends on the provider application. Service model dependencies may be:
– information dependency – the consumer needs information supplied by the
service provider, in which case he addresses a request for information (RFI)
– delegation dependency – the consumer delegates part of its processing to the
service provider, in which case he addresses a request for processing (RFP).
This distinction is orthogonal to that of different modes of interaction:
– blocking mode – the consumer remains suspended until the provider has finished
processing its request, even if it has no information to return,
– non-blocking mode – the consumer may resume before the provider starts
processing its request; sometimes the consumer may wish to retrieve a possible response
or status later,
– publish-subscribe mode – the consumer subscribes to a certain type of
information supplied by the provider. The consumer is later notified by the provider each
time a corresponding information item is available.</p>
      <p>Blocking and unblocking modes may be used for both RFI and RFP, while publish–
subscribe generally implements an RFI. We will come back in section 3 on the fact that
the service orientation cannot be derived simply from the data-flow direction. In our
DvdRental</p>
      <p>Reservations</p>
      <p>Rentals</p>
      <p>CustomerMgmt
Booking</p>
      <p>Accounting
DVD-rental example, a DvdRental application is the service provider that owns and
updates the rental information. The HomeClient acts as a service consumer making
reservation requests from the user’s home. The Staf f Client is another service
consumer, this time for the rental staff at the shop. Both client applications interact with
the server in blocking mode (see Fig. 1).</p>
    </sec>
    <sec id="sec-5">
      <title>Operations and Structures – Syntax</title>
      <p>A service is a set of closely related service operations. Operations are closely related if
they use the same parameter types and access or modify the same persistent
information. Each operation has a signature (name, formal parameters, failure signals).</p>
      <p>The closure of all types of all parameters of all operations belonging to a given
service is the service type model (STM). The STM is part of the service model.</p>
    </sec>
    <sec id="sec-6">
      <title>Semantics and Scope – About producing effects</title>
      <p>The core type model (CTM) is the minimal set of types, attributes and associations
required to specify the service operations. Sharing a CTM between services operations
allows to specify how the side effects of one service affects another service.</p>
      <p>Instances of CTM types have identity and persistent state, they represent the state
between operation invocations of the services sharing the CTM. They are generally
not passed around as operation parameters, and they are not accessible to service
consumers. Fig. 2 shows the CTM for the DVD-rental application.</p>
      <p>Movie
1
*
DvdCopy</p>
      <p>The semantics (the behaviour) of a service operation is defined over both its
parameters and the CTM. The scope of a service operation includes all the CTM types
and attributes referenced by this operation’s specification.</p>
      <p>
        This approach goes one step beyond classical design by contract [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] where the
method scope is normally the class itself. In class contracts, pre- and postconditions
are specified over the method parameters and over the instance variables. For service
operations, pre- and post-conditions are specified over both the operation parameters
and the type instances of the CTM, as suggested by Cheesman and Daniels [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. The
pre- and post-conditions specifications are declarative. Ideally a predicate language
such as OCL [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] is used for formal specification, but natural language making strict
use of the type models and the associations between types yields good results.
      </p>
    </sec>
    <sec id="sec-7">
      <title>Failures – About not producing effects</title>
      <p>The design-by-contract paradigm is radical and unambiguous: preconditions∧operations
⇒ postconditions. This postulate implies that the service provider is free to do anything
if preconditions are not satisfied – including rendering all of its managed information
corrupt. But service providers have a second crucial mission: ensure integrity and
consistency of owned information. The service model declares how preconditions failures
will be handled:
– Checked preconditions – the service model declares all preconditions of the
operation as checked by the provider and defines failure signals which are raised in the
negative case. The service consumer can safely rely on the provider check.
– Unchecked preconditions – the service model explicitly declares the effect of a given
service operation as undefined if its preconditions are not satisfied. The service
consumer can only expect a correct result if it guarantees the precondition.
In practice, unchecked preconditions ideally suit RFIs, whereas checked preconditions
are a natural match for RFPs. In some cases, RFIs may also require checked
preconditions, if the returned information depends crucially from parameters provided and
from state informations in the provider.</p>
      <p>Towards a methodology for Service Oriented Architecture
migration</p>
    </sec>
    <sec id="sec-8">
      <title>Motivation for a SOA migration</title>
      <p>The perspective of this paper with respect to SOA is that of the evolution of existing
large enterprise wide IT-infrastructure, as opposed to the implementation of a SOA
from scratch. What we have in mind is a company with multiple historically grown
applications which size may vary from an application for employees-car park and a
fully fledged ERP.</p>
      <p>Most applications will not operate in isolation but will exchange information. Data
exchange mechanisms may use any type of technologies like: file transfer, data
replication, socket communication, messaging, CORBA or SOAP. Migration to a SOA then
means implementing data exchange between applications as service relationships.</p>
      <p>Although the final result will raise applications equipped with service interfaces,
there is more to be done for a SOA-Migration. It should start with a reverse engineering
and modelling effort before re-engineering the application landscape.</p>
    </sec>
    <sec id="sec-9">
      <title>Architectural principles and migration process</title>
      <p>A successfull SOA-Migration should be guided by following architectural principles:
– Separation of concerns: service relationships must be based on cleaarly established
responsabilities of each participating application.
– Loose coupling: service relationships necessarily couple the service consumer to the
producer. But coupling should be loose where this is possible.
– Reusability: This is the minimal requirement for services. It should be a requirement
even when a service is supposed to be used only by one consumer. Reusability
means that the producer should not expect specificities of the consumer, other
than conditions specified in the service model.</p>
      <p>Separation of concerns implies that for each application, all the supplied services be
specified. These are not only the services for other applications but also those supplied
to business processes, typically through user interfaces. We call the latter business
services.</p>
      <p>We suggest the following steps when applying these principles to a SOA-Migration:
1. Identify the scope of the migration effort and identify all data flows between
applications in the scope.
2. Determine, clarify and optimize dependencies between applications, starting from
existing data flows.
3. Formally specify the service contracts as explained in section 2.
4. Choose the most appropriate technology for implementing each service model.
5. Implement and deploy service.</p>
    </sec>
    <sec id="sec-10">
      <title>Design decisions in SOA reengineering</title>
      <p>Separation of concerns is an important aspect of step 2. In fact the direction of
dependency is not immediately given by the direction of the data flow. A data flow from
application A to B may as well be the interpreted as an information dependency of
B from A than as a delegation dependency of A from B. Suppose a file of customer
transactions being transferred from DvdRental to Accounting. Does this represent an
information dependency of Accounting on DvdRental or rather a delegation
dependency of DvdRental on Accounting? It may well be that John in charge of DvdRental
thinks that the Accounting application needs his data to do their accounting, whereas
Mary in charge of Accounting argues that DvdRental needs her processing to have
their accounts settled.</p>
      <p>How a dependency is modelled at this step is an important decision for the separation
of concerns. In our example (see Fig. 3) one model would mean that DvdRental
provides the business service of handling and billing rental events including book keeping,
but the latter is delegated to accountability. In this perspective DvdRental is
delegation dependent from Accounting. An other way is to consider Accounting as providing
book keeping services to the business. To do so it needs information from DvdRental
and thus is now information dependent from this application.</p>
      <p>Sell and keep
Accounts</p>
      <p>DvdRental</p>
      <p>Accounting</p>
      <p>RFP</p>
      <p>Booking</p>
      <p>Sell
DvdRental</p>
      <p>RFI
Give sales
informations</p>
      <p>Settle
accounts
In step 3 loose coupling may be achieved by avoiding blocking RPC each time
it makes sense. The alternative to blocking RPC depends on the kind of service
dependency: RFI or RFP. In the case of RFI, an RPC mechanism may be replaced by a
publish subscribe protocol, where the service provider notifies events to the service
consumer. In the case of RFP loosest coupling may be achieved when the service provider
does not return any information about the success of the processing. This means that
the service contract garantees processing for all data delivered that conforms to the
pre-conditions and all possible failures are handled by the service provider. This
requires careful specification of the service contract.</p>
      <p>It appears that the case where delegation dependency is realized with a service that
does not return any success confirmation looks very similar to a publish/subscribe type
information dependency (in reverse direction). Thus, one might suggest that a typical
pattern consists in replacing a blocking delegation dependency by an publish/subscribe
type information dependency in reverse direction. This may well be interpreted as a
argument for event driven service architecture where autonomous applications with
clear responsibilities, providing well defined business services, publish events that are
used by others.</p>
      <p>Choosing the most appropriate technical implementation should be a consequence of
the design decisions discussed so far, of available technologies and feasablity in a given
environment. Web services is definitely not the only way of implementig SOA. Message
oriented middleware (possibly combined with SOAP) may be an excellent solution for
RFP but also to implement publish/subscribe style RFI. However we think that even
file transfer may still have its role to play in a service architecture.
4</p>
      <sec id="sec-10-1">
        <title>Conclusion</title>
        <p>Service models and contracts encourage designers and maintainers of a Service–Oriented
Architecture to make explicit descriptions of their services functionalities. The model
proposed in section 2 shows that this may go well beyond definition of services
signatures and parameters types. Analysis of interfaces between applications in terms of
service contracts may help to master crucial issues of enterprise-wide systems
integration. While migrating an architecture towards a SOA approach, we recommend a
process where service models and contracts are used as a formalism organize at best
the overall dependencies between existing applications before making any change in
the technology used for the implementation of services.</p>
        <p>Further research need being made on migration projects of different scales to
measure the impact of this approach and its effect on time, when evolution of information
systems become necessary without missing out on the benefits of existing and running
services. The hypothesis we would like to verify is that this approach lowers the effort
and cost of evolution of an IT infrastructure.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. OASIS:
          <article-title>Reference model for service oriented architectures</article-title>
          . Working draft, OASIS open group (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Parnas</surname>
            ,
            <given-names>D.L.</given-names>
          </string-name>
          :
          <article-title>On the criteria to be used in decomposing systems into modules</article-title>
          .
          <source>Commun. ACM</source>
          <volume>15</volume>
          (
          <issue>12</issue>
          ) (
          <year>1972</year>
          )
          <fpage>1053</fpage>
          -
          <lpage>1058</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. Meyer, B.:
          <article-title>Applying ”Design by Contract”</article-title>
          .
          <source>IEEE Computer</source>
          <volume>25</volume>
          (
          <issue>10</issue>
          ) (
          <year>1992</year>
          )
          <fpage>40</fpage>
          -
          <lpage>51</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Heckel</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lohmann</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Towards contract-based testing of web services</article-title>
          .
          <source>ENTCS</source>
          <volume>82</volume>
          (
          <issue>6</issue>
          ) (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Tosic</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pagurek</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Patel</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>WSOL - a language for the formal specification of classes of service for web services</article-title>
          . In Zhang, L.J., ed.
          <source>: ICWS</source>
          , CSREA Press (
          <year>2003</year>
          )
          <fpage>375</fpage>
          -
          <lpage>381</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Christensen</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Curbera</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meredith</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weerawarana</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Web services description language (WSDL)</article-title>
          , http://www.w3.org/TR/wsdl (
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. Keller, A.,
          <string-name>
            <surname>Ludwig</surname>
          </string-name>
          , H.:
          <article-title>The WSLA framework: Specifying and monitoring service level agreements for web services</article-title>
          .
          <source>J. Network Syst. Manage</source>
          .
          <volume>11</volume>
          (
          <issue>1</issue>
          ) (
          <year>2003</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Sahai</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Durante</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Machiraju</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          :
          <article-title>Towards automated SLA management for web services</article-title>
          .
          <source>Technical report</source>
          , Software Technology Laboratory, HP Laboratories Palo Alto (
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Cheesman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Daniels</surname>
            ,
            <given-names>J.: UML</given-names>
          </string-name>
          <string-name>
            <surname>Components</surname>
          </string-name>
          ,
          <article-title>A Simple Process for Specifying Component-Based Software</article-title>
          .
          <string-name>
            <surname>Addison-Wesley</surname>
          </string-name>
          (
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. OMG:
          <article-title>Unified modeling language (UML), version 2</article-title>
          .0, http://www.omg.org/technology/documents/formal/uml.htm (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>