If you reached this blog, then may be you have heard about SOA and testing SOA applications, or may be you understand testing and would like to know what SOA testing is all about or maybe you want to know what SOA and testing is all about… J Well however complicated your case may be.. I would explain SOA and testing SOA applications in an uncomplicated way to you in a series of blogs and this is the very first blog on it.

 

SOA, stands for Service Oriented Architecture. It describes IT infrastructure which allows different applications to exchange data with one another as they participate in business processes. The aim is a loose coupling of services with operating systems, programming languages and other technologies which underlie applications. [1] .

 

These services inter-operate based on a formal definition (or contract, e.g., WSDL) that is independent of the underlying platform and programming language. Services written in C# running on .NET platforms and services written in Java running on Java EE platforms, for example, can both be consumed by a common composite application (or client). Applications running on either platform can also consume services running on the other as Web services, which facilitates reuse.

 

Let’s understand the term ‘Web Service’. A Web Service in simplistic terms is a web enabled API, that can be accessed over the network. In the SOA architecture it is one component which takes care of a specified business need. Each web service has its own contract file which is required to communicate with it. This contract file is termed as WSDL, which is defined as, ‘Web Service Description Language’. As clear from the name, it provides information about what a web service is all about. The kind of information you can fetch from the WSDL file are:

  1. Where the web service is hosted.
  2. What functionality the web service provides.
  3. What all methods a web service consist of.
  4. What arguments the web service takes and what response it returns.

Lets take an example web service and its wsdl file and try to make sense out of it. The example web service is ‘MoneyConverter’, this service converts a currency value provided in Indian Rs, to Dollars and vice versa. It solves a business requirement and will consist of two methods, you guessed them right:

 

  1. RupeesToDollars
  2. DollarsToRupees

 

Lets take a look at the WSDL file for this service, which is an xml file describing this web service. [File attached]

 

To decipher the WSDL document, lets begin from the end. The last xml node of the wsdl file provides information where the service is hosted.

 

“<wsdl:service name=”Converter”>

<wsdl:documentation xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>A web service for converting currencies</wsdl:documentation>

<wsdl:port name=”ConverterSoap” binding=”tns:ConverterSoap”>

<soap:address location=http://localhost/Converter/Converter.asmx” />

</wsdl:port>”

 

Moving up, we find information about what all methods are present and what arguments they take and the return value.

 

wsdl:portType name=”ConverterSoap”>

<wsdl:operation name=”RupeesToDollar”>

<wsdl:documentation xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>Convert from Rupees to Dollars</wsdl:documentation>

<wsdl:input message=”tns:RupeesToDollarSoapIn” />

<wsdl:output message=”tns:RupeesToDollarSoapOut” />

</wsdl:operation>

<wsdl:operation name=”DollarToRupees”>

<wsdl:documentation xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>Convert from Dollars to Rupees</wsdl:documentation>

<wsdl:input message=”tns:DollarToRupeesSoapIn” />

<wsdl:output message=”tns:DollarToRupeesSoapOut” />

</wsdl:operation>

</wsdl:portType>

 

Now we would like to know what does the input message looks like, and the output, For this lets move a bit up the document.The “wsdl type” xml node defines all the data types which are passed as arguments or returned as response after the method invocation. Lets take one node and explain it further:

 

<s:element name=”RupeesToDollar”>

<s:complexType>

<s:sequence>

<s:element minOccurs=”1″ maxOccurs=”1″ name=”amount” type=”s:decimal” />

</s:sequence>

</s:complexType>

</s:element>

It states that the element is of type ‘decimal’, name of the element is ‘amount’, and it is a mandatory argument for the method, which can be understood by the minoccurs and maxoccurs attributes of the s:element node.

 

So, from the above information provided by the WSDL document of the MoneyConverter, we now know the following;

 

  1. The port where the web service is hosted.
  2. The methods which are present in the web service.
  3. The arguments and the return value of each method of the web service.

 

Empowered with all this information, in the next blog series we will understand how we exactly use this web service, so that we are more enlightened to test it.

 

References:

 

  1. Newcomer, Eric; Lomow, Greg (2005). Understanding SOA with Web Services. Addison Wesley. ISBN 0-321-18086-0.