Tuesday, January 24, 2012

Service Oriented Architecture

Background:

Today, the value is not defined as much by functionality but by connectivity
We are reaching a new threshold of connectivity and computing power, SOA evolves from previous distributed computing envmt



What is SOA?

1. SOA is a architectural style of creating and using business processes packaged as services throughout their 2. lifecycleAn architectural and design discipline to achieve the goals of increased interoperability
3. SOA enables heterogeneous applications to exchange information
4. SOA platform, language neutral
5. SOA evolves from older concepts of distributed computing

What is Service? 

A service is a function that is well-defined, self-contained, and does not depend on the context or state of other services A “service” is the atomic unit of an SOA
Services encapsulate a business process
Most well-known instance is Web  Services

What is Web Service?

Reusable software components that expose a service on the web
Independent of operating systems, programming languages
Invocation through protocol called SOAP over the web
Reusable

Why SOA?

This style of architecture promotes reuse at the macro(service) level rather than micro(classes) level
Simplifies the interconnection to existing IT assets (Legacy)
Reusability, Interoperability, Loose coupling, Usability
Easy maintenance of software assets

SOA Actors:
 The following diagram would give fair idea on various actors involved and their interactions.



Understanding SOA:

The basic and high level concept in SOA is shown below




SOA Standards

SOAP – Simple Object Access Protocol, A service request and response is done using SOAP.
WSDL – Web Service Description Language.
UDDI – Universal Description Discovery and Integration
BPEL – Business Process Execution Language

SOAP

Simple Object Access Protocol used to access a web service over the web
An XML message based protocol (XML document with pre-defined format); sits on the top of HTML
Format:
Envelope – message content
Header – header info
Body – Call and response information
SOAP is Platform, language neutral
Essentially provides the envelope for sending the Web Services messages.
SOAP generally uses HTTP, but other means of connection may be used.

Sample SOAP request message

 <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <ns1:getProductPrice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Example">
      <in0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Spyder</in0>
    </ns1:getProductPrice>
  </soapenv:Body>
</soapenv:Envelope>

Sample SOAP response message


<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.
w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
 <ns1:getProductPriceResponse soapenv:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:ns1="urn:Example">
   <ns2:result xmlns:ns2="http://www.w3.org/2003/05/soap-rpc">getProductPriceReturn</ns2:result>
   <getProductPriceReturn xsi:type="ns3:string" xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/">Product1 price = 4500$</getProductPriceReturn>
  </ns1:getProductPriceResponse>
 </soapenv:Body>
</soapenv:Envelope>

WSDL

Web Service Description Language
XML based grammar for describing a web service
Has information about what methods are available in the web service, parameters, return types etc
WSDL helps consumers to consume the web service

WSDL Elements



UDDI

Stands for Universal Description Discovery and Integration
A registry rather than repository that contains reference  information of web services
Service providers register web service and consumers find information of web service in UDDI
Two types: 1) Public Registry  2) Private Registry

Overall Interaction



Overall Look at SOA and its invocation



Creating a new Web Service using Axis

Create an interface with required methods and run it using Java2WSDL utility (available under Apache Axis2) giving following command line arguments
"-o productprice.wsdl -l"http://localhost:8080/axis/services/ProductPrice" -n  "urn:Example" -p"com.company.webservices" "urn:Example" com.company.webservices.ProductPrice

Create Bindings using WSDL2Java:
 java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -S true -Nurn:Example com.company.webservices productprice.wsdl

o indicates the name of the output WSDL file
-l indicates the location of the service
-n is the target namespace of the WSDL file
-p indicates a mapping from the package to a namespace. There may be multiple mappings.
the class specified contains the interface of the webservice.
-s server-side
-S, --skeletonDeploy <argument> deploy skeleton (true) or implementation (false) in deploy.wsdd.
-d Deploy scope

Web Services can be created in any programming language and any platform, but all web services expose an interface (WSDL) that is understandable the web service clients. (Consumers)
In Java, an open source tool called Apache Axis, can also be called as a SOAP server can be used for creating a new web service or writing a web service client for an existing web service
The Axis works with Apache Web Server and has APIs to process WSDL to generate web service client code or creating a WSDL file out of an interface (new web service)
WSDL2Java – Web service client
Java2WSDL -  New web service

Deploy/Undeploy web service

Deploy.wsdd to deploy the service on the server
Use AdminClient to deploy your service
Command lines,
AdminClient <deploy.wsdd-file>
Confirmation message

SOA Benefits

Business Benefits:
-Focus on Business Domain solutions
-Leverage Existing Infrastructure
-Agility
 Technical Benefits:
-Loose Coupling
-Autonomous Service
-Location Transparency
-Late Binding

SOA Limitations

SOA or Web Services are not suited for stand alone, non-distributed environments
Consumers may not apply the specified privacy policies to the exposed service

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...