Services Oriented Architectures

by Sandeep Desai (http://www.thedesai.net/sandeep)



SOA is an abstract architectural concept in which automation logic is decomposed into individual services

 

SOA is built primarily using Web services framework consisting of WSDL, SOAP, XML

 

SOAP defines a standard format for the message exchange

SOAP Version 1.2 is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. It uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.

 

 

WSDL is a language independent definition to describe the Web service

 

WS Standards

 

BPEL (Business Process Execution Language)

 

 

ESB (Enterprise Service Bus)

 

Development approaches

 

SOA 2.0

 

 

REST

 

JAX-RPC Java Based API for working with SOAP has client stub and server endpoint. Uses WSDL

 

Oracle JDeveloper

 

Standards

 

JBI (Java Business Integration)

 

 

JDeveloper Web Services

 

To create secure web services using WS-Security

Create keystore with following command

 

keytool -genkey -dname "CN=sandeep, OU=sandeepDept, O=sandeepOrg, L=sandeepHome, S=Florida, C=US" -keyalg RSA -sigalg Sha1WithRSA -keystore mytestkeystore.jks -alias saturn

 

Java Web Service Code

package net.thedesai.soa;

 

import java.util.ArrayList;

import java.util.Calendar;

import java.util.GregorianCalendar;

 

import java.util.List;

 

import javax.jws.WebService;

 

@WebService(name = "GetDateWS", serviceName = "GetDateWS")

public class GetDates {

    public GetDates() {

    }

 

    public Calendar getDate() {

        return Calendar.getInstance();

    }

 

    public Calendar getDateHence(int daysHence) {

        GregorianCalendar myCalendar = new GregorianCalendar();

        myCalendar.add(GregorianCalendar.DATE, daysHence);

        return myCalendar;

    }

 

    public String sayHello() {

        return "Hello!";

    }

   

    public List<Person> getPersons() {

        List<Person> persons = new ArrayList();

        persons.add(new Person("foo", 123));

        persons.add(new Person("bar", 456));

        return persons;

    }

}

 

package net.thedesai.soa;

 

public class Person {

    public Person() {}  

    public Person(String name, int salary) {

        this.name = name;

        this.salary = salary;

    }

   

    public int getSalary() { return salary;   }   

    public void setSalary(int salary) { this.salary = salary;   }

  

    public String getName() { return name;   }

   

    public void setName(String name) { this.name = name;  }

   

    private int salary;

    private String name;

}

 

WSDL Example (Generated from JDeveloper)

<definitions

     name="GetDateWS"

     targetNamespace="http://soa.thedesai.net/"

     xmlns="http://schemas.xmlsoap.org/wsdl/"

     xmlns:tns="http://soa.thedesai.net/"

     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"

     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"

     xmlns:tns0="http://soa.thedesai.net/types/"

     xmlns:xsd="http://www.w3.org/2001/XMLSchema"

     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

     xmlns:tns1="http://www.oracle.com/webservices/internal/literal"

    >

    <types>

        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soa.thedesai.net/types/"

             elementFormDefault="qualified" xmlns:tns="http://soa.thedesai.net/types/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"

             xmlns:ns1="http://www.oracle.com/webservices/internal/literal">

            <import namespace="http://soa.thedesai.net/"/>

            <import namespace="http://www.oracle.com/webservices/internal/literal"/>

            <complexType name="getDate">

                <sequence/>

            </complexType>

            <complexType name="getDateResponse">

                <sequence>

                    <element name="return" type="dateTime" nillable="true"/>

                </sequence>

            </complexType>

            <complexType name="getDateHence">

                <sequence>

                    <element name="param0" type="int"/>

                </sequence>

            </complexType>

            <complexType name="getDateHenceResponse">

                <sequence>

                    <element name="return" type="dateTime" nillable="true"/>

                </sequence>

            </complexType>

            <complexType name="getPersons">

                <sequence/>

            </complexType>

            <complexType name="getPersonsResponse">

                <sequence>

                    <element name="return" type="ns1:list" nillable="true"/>

                </sequence>

            </complexType>

            <complexType name="sayHello">

                <sequence/>

            </complexType>

            <complexType name="sayHelloResponse">

                <sequence>

                    <element name="return" type="string" nillable="true"/>

                </sequence>

            </complexType>

            <complexType name="Person">

                <sequence>

                    <element name="name" type="string" nillable="true"/>

                    <element name="salary" type="int"/>

                </sequence>

            </complexType>

        </schema>

        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.oracle.com/webservices/internal/literal"

             elementFormDefault="qualified" xmlns:tns="http://www.oracle.com/webservices/internal/literal"

             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">

            <import namespace="http://soa.thedesai.net/"/>

            <import namespace="http://soa.thedesai.net/types/"/>

            <complexType name="list">

                <complexContent>

                    <extension base="tns:collection">

                        <sequence/>

                    </extension>

                </complexContent>

            </complexType>

            <complexType name="collection">

                <sequence>

                    <element name="item" type="anyType" minOccurs="0" maxOccurs="unbounded"/>

                </sequence>

            </complexType>

        </schema>

        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soa.thedesai.net/"

             elementFormDefault="qualified" xmlns:tns="http://soa.thedesai.net/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"

             xmlns:ns1="http://soa.thedesai.net/types/">

            <import namespace="http://www.oracle.com/webservices/internal/literal"/>

            <import namespace="http://soa.thedesai.net/types/"/>

            <element name="getDate" type="ns1:getDate"/>

            <element name="getDateResponse" type="ns1:getDateResponse"/>

            <element name="getDateHence" type="ns1:getDateHence"/>

            <element name="getDateHenceResponse" type="ns1:getDateHenceResponse"/>

            <element name="getPersons" type="ns1:getPersons"/>

            <element name="getPersonsResponse" type="ns1:getPersonsResponse"/>

            <element name="sayHello" type="ns1:sayHello"/>

            <element name="sayHelloResponse" type="ns1:sayHelloResponse"/>

        </schema>

    </types>

    <message name="GetDateWS_getDate">

        <part name="parameters" element="tns:getDate"/>

    </message>

    <message name="GetDateWS_getDateResponse">

        <part name="parameters" element="tns:getDateResponse"/>

    </message>

    <message name="GetDateWS_getDateHence">

        <part name="parameters" element="tns:getDateHence"/>

    </message>

    <message name="GetDateWS_getDateHenceResponse">

        <part name="parameters" element="tns:getDateHenceResponse"/>

    </message>

    <message name="GetDateWS_getPersons">

        <part name="parameters" element="tns:getPersons"/>

    </message>

    <message name="GetDateWS_getPersonsResponse">

        <part name="parameters" element="tns:getPersonsResponse"/>

    </message>

    <message name="GetDateWS_sayHello">

        <part name="parameters" element="tns:sayHello"/>

    </message>

    <message name="GetDateWS_sayHelloResponse">

        <part name="parameters" element="tns:sayHelloResponse"/>

    </message>

    <portType name="GetDateWS">

        <operation name="getDate">

            <input message="tns:GetDateWS_getDate"/>

            <output message="tns:GetDateWS_getDateResponse"/>

        </operation>

        <operation name="getDateHence">

            <input message="tns:GetDateWS_getDateHence"/>

            <output message="tns:GetDateWS_getDateHenceResponse"/>

        </operation>

        <operation name="getPersons">

            <input message="tns:GetDateWS_getPersons"/>

            <output message="tns:GetDateWS_getPersonsResponse"/>

        </operation>

        <operation name="sayHello">

            <input message="tns:GetDateWS_sayHello"/>

            <output message="tns:GetDateWS_sayHelloResponse"/>

        </operation>

    </portType>

    <binding name="GetDateWSSoapHttp" type="tns:GetDateWS">

        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <operation name="getDate">

            <soap:operation soapAction=""/>

            <input>

                <soap:body use="literal" parts="parameters"/>

            </input>

            <output>

                <soap:body use="literal" parts="parameters"/>

            </output>

        </operation>

        <operation name="getDateHence">

            <soap:operation soapAction=""/>

            <input>

                <soap:body use="literal" parts="parameters"/>

            </input>

            <output>

                <soap:body use="literal" parts="parameters"/>

            </output>

        </operation>

        <operation name="getPersons">

            <soap:operation soapAction=""/>

            <input>

                <soap:body use="literal" parts="parameters"/>

            </input>

            <output>

                <soap:body use="literal" parts="parameters"/>

            </output>

        </operation>

        <operation name="sayHello">

            <soap:operation soapAction=""/>

            <input>

                <soap:body use="literal" parts="parameters"/>

            </input>

            <output>

                <soap:body use="literal" parts="parameters"/>

            </output>

        </operation>

    </binding>

    <service name="GetDateWS">

        <port name="GetDateWSSoapHttpPort" binding="tns:GetDateWSSoapHttp">

            <soap:address location="http://138.1.196.199:8888/soa-getdates-context-root/GetDateWSSoapHttpPort"/>

        </port>

    </service>

</definitions>

 

Links

 

 

Books