Showing posts with label SOA 11g. Show all posts
Showing posts with label SOA 11g. Show all posts

Monday, 23 July 2012

Exception driven BPEL Salesforce Authentication




Salesforce Authentication with Oracle SOA ("Exception-driven Authentication")


In this Blog , I will be sharing a different approach we followed in EAI (BPEL) to invoke the Salesforce Services. The requirement was to invoke Salesforce REST API which uses 

OAuth 2.0 (by passing a session ID in the HTTP Authorization Header) for Authorization.It was confirmed that the Salesforce Login Session Id would remain active for 8 hours.
Hence BPEL need not  to perform the SFDC Login call for every incoming request.[Guessed it right!! we need Cache it internally]




The approach was - 

"Exception driven Authentication " where in,Salesforce login flow would be only triggered in case of INVALID SESSION exception, while making call to salesforce REST API


The Login Scope ensure that once the 

SFDC Login  retrieves a new session Id, it replays the Salesforce REST API flow, but this time using  the new session Id,expecting the same to work this time.



for the fact that salesforce session id would remain active for next 8 hours, We also cache the sessionid in in the Xref table.,so that  a regular look-up and reuse of the session can be done for all subsequent request that follows.










SF Login + Caching done in case of  Invalid-session


I chose to use Xref tables because,
felt that this was right place to dynamically update and retrieve the  session-Id as per demand.



[.....but again,you might follow a different approach to store the same as in a global Variable or property file..but never in a DVM- definitely this is not meant to store any dynamic/configuration data :) ]


Wednesday, 23 May 2012

BPEL Component as a REST SERVICE(using HTTP Adapter)



BPEL Component as  a REST SERVICE(using HTTP Adapter)



 
Task: To expose a SOA Component (a BPEL Service Here ) as a REST (HTTP based) service using HTTP Binding Adapter



  • Open A new Empty SOA Project.

  • Go to Composite.xml->Drop the HTTPBinding Adapter  from component pallet @ the left to to the Exposed Services Swimlane at the LeftHandSide


f9564-rest1


  • Follow the below screen shot to configure & complete the HTTP Binding Wizard.


  • You may use any schema for configuring the request and response Message structure withing the HTTPBinding .

     

    BPELProcess1.xsd

     

    <?xml version="1.0" encoding="UTF-8"?>

    <schema attributeFormDefault="unqualified"

        elementFormDefault="qualified"

        targetNamespace="http://xmlns.oracle.com/Application1/Project1/BPELProcess1"

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

        <element name="process">

            <complexType>

                <sequence>

                    <element name="input" type="string"/>

                </sequence>

            </complexType>

        </element>

        <element name="processResponse">

            <complexType>

                <sequence>

                    <element name="result" type="string"/>

                </sequence>

            </complexType>

        </element>

    </schema>



    • Step 1,Step2 and Step3 for HTTP Binding Wizard




5961d-rest7

 

 

 



  • Note:In HTTP Binding wizard Step 4:Verb and Payload-Type can be manipulated by manually edited in the composite.xml later and



ef949-rest3

 

 

 

Once The Adapter is configure for being exposed as a service.,


  • Drop an empty BPEL Process in the component area.

  • Open the BPEL and complete the desired flow using a receive and reply activity witha desired transformation between these .


 


878d3-rest4

 

To make available all the HTTP Methods for the service both GET and POST , composite so that HTTP Bindings comes with its default behavior remove the properties that appear in composite

9ecda-rest5

 

So that once deployed the composite , you have the blow shown methods available for invocation.


028cf-rest6



Thursday, 26 April 2012

Schematron Validation in SOA 11G Mediator


 


Schematron  Rule-based validation - Schematron.
This standard is available free on the ISO Publicly Available Specifications list. Paper versions may be purchased from ISO or national standards bodies.

Schemas that use ISO/IEC FDIS 19757-3 should use the following namespace:
http://purl.oclc.org/dsdl/schematron

Sample rule
Schematron rules can be created using a standard XML editor.

The following is a sample schema:

xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<title>Date rules</title>
<rule context="Contract">
ContractDate < current-date()">ContractDate should be in the past because future contracts are not allowed.
</rule>
</pattern>
</schema>

In Plain words:
This rule checks to make sure that the ContractDate XML element has a date that is before the current date. If this rule fails the validation will fail and an error message which is the body of the assert element will be returned to the user.

In markup languages, Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a structural schema language expressed in XML using a small number of elements and XPath.

Schematron Validation in SOA 11G Mediator

  • The schematron validation allows loose coupling of Semantic validation of the incoming/outgoing mediator payload.This is accomodated while defining the routing rule for mediator payloads.



  • The Schematron file is created with a file type having an .sch extention.



  • This file can be maintained in  the project workspace or alternately as artifact in MDS repository for taking the real advantage of loose coupling of validation semantics.


In below example I have maintained the schematron file in my Mediator project work space.

when assertion (i.e. the asserted  test statement) evaluates to false, the asseted statement is thrown as validation error.

Deploy and test the Mediator from SOAP UI.





 

Thursday, 5 January 2012

Setting Mediator Instance Title

You may create the mediator custom title using the  Routing rule assign activity  within the mediator component

  
You would need to choose the Mediator Extention Function: med:setCompositeInstanceTitle() to build your custom title on the LHS against the property tracking.compositeInstanceTitle on the RHS.













Once the Mediator is deployed and Instance as are triggered final result would look as below:









- rITZ...