Thursday, February 6, 2020

12c SOA - DB Adapter - Perform select operation on a table

Here I will do:
  • Create a table Employee and insert some employee rows.
  • Create a DB Adapter and fetch the employee data based on employee id.
  • Create a synchronous BPEL service and call the DB adapter
Create a table:
create table employee
(
emp_id number(10) not null,
emp_fname varchar2(50),
emp_lname varchar2(50),
dept_id varchar2(50),
dept_name varchar2(50),
emp_type varchar2(50),
CONSTRAINT customers_pk PRIMARY KEY(emp_id)
)
Insert Data:
insert into employee values (1,'Sri','Das','123','OSP','P')

insert into employee values (2,'Dip','Cha','123','OSP','S')

 Create a SOA project



 Right click on the External References lane ⇾Insert⇾Databse
 Provide the adapter name
 Create the DB connection

 Provide the JNDI Name and if you don't have any JNDI then create it in admin console.
 Select Perform an Operation on a table
 Import Tables
 Give the table name in the filter and select it.


 Next
 Next
 Add a parameter
 Name the Parameter.
 Click Edit
 Add
 Select Parameter
 Select created EmpId as parameter

 Next
 Next
 Next
 DB Adapter created.
Now Right click on components and insert BPEL Process
 Select Synchronous service
 Modify the XSD

 Wire the BPEL with the adapter

 Drag and drop an invoke activity and call the adapter partnerlink
 create the invoke input and output

 Assign the Input

 Assign the output

 Deploy and test


Wednesday, February 5, 2020

12c SOA - set custom jms header property in Mediator and BPEL components and message selector syntax for jms consume

By Default a JMS message includes a number of header fields that contain information used to identify and route messages. The supported headers for an incoming message are:
JMSCorrelationID
JMSDeliveryMode
JMSExpiration
JMSMessageID
JMSPriority
JMSRedelivered
JMSTimestamp
JMSType

But we can also set Custom properties.

Mediator: To set custom JMS header property in Mediator follows below steps.

Open .mplan file and click on assign activity. Here we are defining new custom header property (city).
To set city custom header property choose “jca.jms.JMSProperty” and append “.city” to it. You can assign any expression or hard-code this property value.

BPEL: To set custom JMS header property in BPEL follows below steps.
Go to *.bpel file, check the invoke code and add a new property called jca.jms.JMSProperty.Profession, for instance:

<invoke name="InvokeJMS" inputVariable="InvokeJMS_Produce_InputVariable"
                partnerLink="JMSProduce" portType="ns1:Produce_Message_ptt"
                operation="Produce_Message" bpelx:invokeAsDetail="no">
                 <bpelx:inputProperty name="jca.jms.JMSProperty.Profession" variable="profVar"/>
</invoke>

Currently this property is equal to profVar but you can also use expression to assign value to city property.
 <bpelx:inputProperty name="jca.jms.JMSProperty.Profession" expression="2"/>

Remember you will not find this property in header tab, you need to manually set this property in *.bpel file for specific invoke.

When you will run the composite, you will see custom JMS header property at admin console for that queue.

Deploy and Test:
 In JMS queue weblogic console
 Consume message using message selector 

Monday, January 27, 2020

12c SOA BPEL - Error - "fromValue is not a sref:service-ref element"

Problem Description:
In BPEL 1.1, We can achieve the dynamic partnerlink using simple ws-addressing but In BPEL 2.0, its not that simple. If we want to do with only ws-addressing, it will throw the following error:

<selectionFailure xmlns=”h ttp://docs.oasis-open.org/wsbpel/2.0/process/executable”>
<part name=”summary”>
<summary>fromValue is not a sref:service-ref element</summary>
</part>

Solution:
We can achieve the dynamic partnerlink in BPEL 2.0 without the error. For that we have to use EndpointReference element of ws-addressing.xsd and service-ref element of ws-bpel_serviceref.xsd.

Please visit here 12c-soa-bpel-20-dynamic-partner-link for the dynamic partnerlink implementation steps using EndpointReference element of ws-addressing.xsd and service-ref element of ws-bpel_serviceref.xsd.

12c SOA - BPEL 2.0 - Dynamic Partner link

The dynamic partnerlink feature enables us to dynamically assign an endpoint reference to a partnerlink for use at runtime in BPEL versions 1.1 and 2.0.

Scenario where we can use :
Let suppose there is a requirement to design process for which the end point is not fixed i.e. there are multiple end points that can be used. In an ideal scenario a developer will define multiple partnerlink and will write separate logic to use them. This will un necessarily complicate the code. This can be simplified using a single dynamic partnerlink. In order to achieve this we will first create the required number of web services (end point URL) based on same wsdl. These will be a simple web services which will accept the input, will do some enhancement and will return it back to the calling service. Next is we will define another process where in we will define a dynamic partnerlink to call these end point url based on input. In order to achieve this a variable will be created based on ws-addressing Endpoint-reference (more detail on the implementation). This variable will serve as an input to the dynamic partnerlink for deciding on which web service has to be called. Based on the input this variable will be updated with the end point url of the predefined web services and the services will be called dynamically.

In BPEL 1.1, We can achieve the dynamic partnerlink using simple ws-addressing but In BPEL 2.0, its not that simple. If you want to do with only ws-addressing, it will throw the following error:
"fromValue is not a sref:service-ref element"

Implementation steps:
  • First create a VersionProject and deploy the project with 3 versions 1.0, 2.0 and 3.0. 
  • Then create Dynamicpartnerlick project where it will take inputs Msg and Url.
  • It will invoke the version project version 1.0 only. 
  • Then create following 3 variables 
  1. variable varURL based on Project Input Url schema.
  2. variable varAddress1 based on EndpointReference element of ws-addressing.xsd 
  3. variable serviceRef based on service-ref element of ws-bpel_serviceref.xsd
  • Next, following 3 assigns and 1 Transformation:
  1. Msg assigned to Input of invoked service
  2. input Url assigned to $varURL/client:url
  3. Transformation varURL to serviceRef (Structured defined later)
  4. serviceRef  assigned to VeresionProject partner link.
Implementation with BPEL 2.0:

Create synchronous VersionProject.






 Created Service WSDLs:
http://localhost:8001/soa-infra/services/POC/VersionProject!1.0*soa_a685a792-9a15-4d82-9e95-956c3e2e5b1d/versionprocess_client_ep?WSDL
 http://localhost:8001/soa-infra/services/POC/VersionProject!2.0*soa_a685a792-9a15-4d82-9e95-956c3e2e5b1d/versionprocess_client_ep?WSDL
 http://localhost:8001/soa-infra/services/POC/VersionProject!3.0*soa_a685a792-9a15-4d82-9e95-956c3e2e5b1d/versionprocess_client_ep?WSDL

Create synchronous DynamicPartnerlinkProject


 Modify the XSD as below
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/SOAApplication/DynamicPartnerLinkProject/DynamicClientProcess"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="msg" type="string"/>
                                <element name="url" type="string"/>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
 Invoke the SOAP service - Version project v1.0 WSDL.


 Open the BPEL
 Create the mentioned 3 variables.


 Assigns the Msg and Url.
 Transform the Url to serviceref using ws-addressing.
  <xsl:template match="/">
    <tns:service-ref>
      <EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">
        <Address>
          <xsl:value-of select="/ns0:process/ns0:url"/>
        </Address>
      </EndpointReference>
    </tns:service-ref>
  </xsl:template>

 Assign the service-ref variable to VersionProject Partnerlink
 Invoke the Version Project Service
 Assign the Result output
 The flow will look like
 Deploy and test with the Url inputs.

Tested with v1.0

 Tested with 2.0

Tested with 3.0


Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...