Tuesday, November 11, 2014

Passing Custom Header from BPEL to OSB and vice versa

Sometimes we might have a requirement to pass some information via Header between BPEL and OSB.

In this post I am trying to explain one of the approaches possible to achieve that requirement

BPEL side
=========================

As a first step, create an xsd as shown below


=============Header.xsd==========================

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://xmlns.oracle.com/Custom/Header"
            targetNamespace="http://xmlns.oracle.com/Custom/Header"
            elementFormDefault="qualified">
  <xsd:element name="SessionHeader" type="SessionHeaderType"/>
  <xsd:complexType name="SessionHeaderType">
        <xsd:sequence>
            <xsd:element name="sessionToken" type="xsd:string"/>
            <xsd:element name="type" type="xsd:string"/>
        </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

===================================================

Create two variables of type SessionHeader in the BPEL Process.

customHeader is to pass header values to the target service.

customHeaderIn is to receive the header values from a response received from target service.









On the invoke activity configure the input and output Header variables as follows


  <invoke name="InvokeTokenProcess" partnerLink="TokenProcess"
            portType="ns1:EmployeePortType" operation="GetEmployeeByEmpId" inputVariable="TokenProcess_IV"
            outputVariable="TokenProcess_OV" bpelx:invokeAsDetail="no" bpelx:inputHeaderVariable="customHeader" bpelx:outputHeaderVariable="customHeaderIn"/>


Use an assign activity before the invoke activity to set the required values in the customHeader variables

After invoke activity use another assign activity to retrieve the passed header- from target service on the customHeaderIn variable




OSB Side
=====================

 The passed custom Header can be retrieved in OSB pipeline as given below




 To send a custom header from OSB use the insert activity as given below



================
Deploy both BPEL and OSB service and do a test to see the header being passed correctly



No comments:

Post a Comment