Monday, January 27, 2020

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


No comments:

Post a Comment

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...