Service-Oriented Architecture (SOA)


Creative Commons License
This Service-Oriented Architecture (SOA) tutorial is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License
Preamble
This lecture is an introduction to Service-Oriented Architecture (SOA). It is mostly illustrated by means of BPMN, BPEL and Java with a focus on business-oriented services.
Characterization
Business services
A business service gathers in one self-contained piece a set of high-cohesive functionalities. This set belongs to a domain: healthcare, finance, air traffic control…
Readers are invited to visit the ProgrammableWeb site to find the ever-increasing richer set of worldwide business services!
Service computing-based business is "business as usual", e.g., outsourcing check writing (www.piracle.com/check-printing-and-writing-software).

Service composition

As a kind of component, a service is subject to composition operations. For example, a Payment business process may call currency conversion functionalities before calling check writing functionalities. One may abstractly express it by means of UML Components Diagrams:

Currency check writing as services
One may also express it in relation with a given technology, say, Web Services :

Currency check writing as Web services
Precise (technology-free) composition may require behavioral details like sequencing of the Payment business process:

Currency check writing BPMN
If Web Services is chosen as the target implementation technology then the most formal approach is the use of WS-BPEL, which allows both the expression and execution of graphical business processes:

Currency check writing WS-BPEL
In WS-BPEL, service invocations (green-rightward/blue-leftward arrows), assignments (equal sign), data reception (green-rightward arrow) and data reply (blue leftward arrow) are language constructs to consistently and completely design business processes. The Payment business process specification in particular points out sequencing and parallelization. As an illustration, retrieving bank account for the write function of the Check writing Web service is parallel with the call of the convert function of the Currency Web service. WS-BPEL capitalizes on the capabilities of the Web Services technology, which automatically favors implementation. In this scope, WS-BPEL models may be associated with effective pre-deployed Web services. WS-BPEL models may consequently be deployed on (and then executed by) a BPEL engine like, for example, Apache Orchestration Director Engine (Apache ODE).

Data feed service

A (business) data feed service is a simple service that is not attached to a specific technology. In most cases, it is accessible from the Web by means of a particular API. As an illustration, we here study a professional currency conversion service (paying service with free simplified version) provided by the Open Exchange Rates Web site. This case study may be downloaded as a Java SE NetBeans project here

Web service

A Web service obeys to the Web Services technology that in essence goes beyond the Java technology. Typically, a Web service may be designed in .NET and consumed in Java. As an illustration, we here study a professional currency conversion service (paying service) provided by the Currency System Web site. From the fx.currencysystem.com/webservices/CurrencyServer5.asmx address, one finds its documentation. It is a SOAP Web service over HTTP or HTTPS. As discussed below, a SOAP Web service requires a WSDL (Web Services Description Language) specification. This SOAP currency conversion service offers a lot of functionalities, including legal information that is often of great importance in finance. In Java, the convert function may be simply (with appropriate included libraries) called as follows:
@javax.xml.ws.WebServiceRef(wsdlLocation = "META-INF/wsdl/fx.currencysystem.com/webservices/CurrencyServer5.asmx.wsdl") // Location of the WSDL specification
com.currencysystem.webservices.currencyserver.CurrencyServer service;
…
com.currencysystem.webservices.currencyserver.CurrencyServerSoap port = service.getCurrencyServerSoap12();
Object o = port.convert(licenseKey, fromCurrency, toCurrency, amount, rounding, format, returnRate, time, type);
The signature of the convert function is in essence the degree of sophistication (and thus functional quality) of the requested service. The licenseKey parameter reveals the paying nature of the call. The convert function is documented in the WSDL specification as follows: fx.currencysystem.com/webservices/CurrencyServer5.asmx?WSDL.
Here is an extract of the WSDL code:
<wsdl:documentation> Currency Server - An exchange rate information and currency conversion Web service. </wsdl:documentation>

<s:element name="Convert">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="licenseKey" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="fromCurrency" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="toCurrency" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="amount" type="s:double"/>
<s:element minOccurs="1" maxOccurs="1" name="rounding" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="format" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="returnRate" type="tns:curncsrvReturnRate"/>
<s:element minOccurs="0" maxOccurs="1" name="time" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="type" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
In this specification, one may for example observe that the rounding is just a Boolean option. The client application must then take in charge of precision/rounding management by setting the rounding parameter to false and later applying a local policy (business rule).
Note: Apache CXF offers tools to automatically generate client programs (consumers) in Java, JavaScript or other languages from WSDL code.

Free service

A Web service differs from another in technology (SOAP, RESTful… see below) and in price! As an illustration, we here study a free currency conversion service provided by the RestFul Web Services Web site. At the www.restfulwebservices.net/service.aspx?ID=2 address, one is able to find the Web service's documentation. In Java, bringing back the desired exchange rate may be simply (with appropriate included libraries) realized as follows:
@javax.xml.ws.WebServiceRef(wsdlLocation = "META-INF/wsdl/www.restfulwebservices.net/rest/CurrencyService.svc.wsdl")
net.restfulwebservices.servicecontracts.rest._2008._01.CurrencyService service;
…
net.restfulwebservices.servicecontracts.rest._2008._01.ICurrencyService port = service.getWebHttpBindingICurrencyService();
Object o = port.getConversionRate(parameters); // Conversion rate acquisition (free), but direct conversion is not supported!
The parameters object (Java type is net.restfulwebservices.servicecontracts.rest._2008._01.GetConversionRate) sent at request time simply has the setFromCurrency and setToCurrency functions to set the source and target currencies. In return, one may obtain the exchange rate from these two values in parameters.
Web Services technology
RESTful Web services have taken the leadership because of their wide take-up by leaders like Google, Amazon, Facebook, etc. RESTful Web services single out the idea of "resource" as the key means to retrieve data from Web places supporting exposed Web services. While RESTful Web services may be described with the help of WSDL, WADL (Web Application Description Language) is the preferred means for that.

Example

As an illustration, we may consume the Google accounts RESTful Web service. The idea is to access a Google account provided that the user of interest has provided rights to third-party applications. Several settings are required from Google before having the possibility of accessing the user's data, see Google Accounts Authentication and Authorization.
// Project name: MTI-UPPA-WebService
// Project ID: oceanic-column-699

Other examples in varied business fields