Wednesday, February 12, 2020

12c SOA -BPEL - How to set the service endPoint URI dynamically using invoke endpointURI property

In BPEL 1.1, We can achieve the dynamic partnerlink using simple ws-addressing but in BPEL 2.0,We can achieve the dynamic partnerlink using EndpointReference element of ws-addressing.xsd and service-ref element of ws-bpel_serviceref.xsd.

Instead of using ws-addressing, as of 11g onwards, we can simply override the endpointURI property on runtime. It is important that the services that we want to invoke all implement the exact same wsdl as referenced in the composite reference. It will have much less clutter in the BPEL.

Use Case :
Here I will show you how to get the URI of the backend service from a repository and how to set it dynamically to our partnerLink (dynamicPartnerLink).

Implementation steps :
  1. Create two synchronous BPEL service VersionProject versions(1.0 and 2.0)
  2. Create a dvm file which stored the service endpoints.
  3. Create a BPEL component and invoke VersionProject(1.0)
  4. Add the endPointURI variable and assign the endpoint uri based on service name
  5. Set the endpointURI property in the invoke activity
Implementation:
Create a SOA Project

 Create a XSD.
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"
            targetNamespace="http://www.dynamiceURL.test" elementFormDefault="qualified">
    <xsd:element name="process">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="msg" type="xsd:string"/>
                <xsd:element name="ServiceName" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="processResponse">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="result" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

 Create a Sync BPEL using the above schema.

 Create a DVM.




 Invoke the SOAP service Version Project v1.0


 Open the BPEL and create the endPointURI variable and fetch the endpoint URI using the dvm lookup function.


<assign name="AssignEndpointURIFromDVM">
<copy>
<from>dvm:lookupValue('Endpoints.dvm','ServiceName',$inputVariable.payload/ns1:ServiceName,'EndPointURI','NotFound')</from>
<to expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">$endpointURI</to>
</copy>
</assign>

Invoke the created partnerlink
 Create the Input and output variables
 Assign the endpointURI variable to endpointURI property
    <invoke name="Invoke_SOAPReference" bpelx:invokeAsDetail="no" partnerLink="SOAPReference"
            portType="ns2:VersionProcess" operation="process"
            inputVariable="Invoke_SOAPReference_process_InputVariable"
            outputVariable="Invoke_SOAPReference_process_OutputVariable">
      <bpelx:toProperties>
        <bpelx:toProperty name="endpointURI" variable="endpointURI"/>
      </bpelx:toProperties>
    </invoke>
 Assign the input to Invoke and Output


 Deploy and test.

Input: Msg: test1 and ServiceName: VersionProject1
Output: It calls the v1.0 service


Input: Msg: test2 and ServiceName: VersionProject2
Output: It calls the v2.0 service



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