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



Monday, February 10, 2020

12c SOA - BPEL - expose service with headers

Here I will show you how to expose a BPEL(Synchronous)  service with header.

Implementation:
Create a SOA Project



 Create an XSD


 XSD Create: for Request - response with header:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.test"
            targetNamespace="http://www.emp.test" elementFormDefault="qualified">
    <xsd:element name="Request">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="EmpId" type="xsd:string"/>
                <xsd:element name="EmpName" type="xsd:string"/>
                <xsd:element name="Address" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
        <xsd:element name="Response">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="result" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="header" type="tRequestHeader"/>
    <xsd:complexType name="tRequestHeader">
        <xsd:sequence>
            <xsd:element name="User" type="xsd:string" minOccurs="0"/>
            <xsd:element name="Id" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

 Create BPEL
 Choose template based on WSDL and generate wsdl from schema.
 Create WSDL: Input will have Header and Request and Output will have Response part.
 Adding header


 Add the Request payload same above way

 Add the Response part.

 BPEL is exposed
 In the BPEL, assign one Header to output result variable.

 Now open the created WSDL and add binding

 The WSDL should look like this.
WSDL:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<wsdl:definitions name="BPELProcess1"
                  targetNamespace="http://xmlns.oracle.com/SOAApplication/ExposeWithHeaderProject/BPELProcess1"
                  xmlns:tns="http://xmlns.oracle.com/SOAApplication/ExposeWithHeaderProject/BPELProcess1"
                  xmlns:inp1="http://www.emp.test" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <plnk:partnerLinkType name="BPELProcess1">
        <plnk:role name="BPELProcess1Provider" portType="tns:execute_ptt"/>
    </plnk:partnerLinkType>
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:import namespace="http://www.emp.test" schemaLocation="../Schemas/EMPloyee.xsd"/>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="requestMessage">
        <wsdl:part name="header" element="inp1:header"/>
        <wsdl:part name="payload" element="inp1:Request"/>
    </wsdl:message>
    <wsdl:message name="replyMessage">
        <wsdl:part name="payload" element="inp1:Response"/>
    </wsdl:message>
    <wsdl:portType name="execute_ptt">
        <wsdl:operation name="execute">
            <wsdl:input message="tns:requestMessage"/>
            <wsdl:output message="tns:replyMessage"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="execute_pttSOAP11Binding" type="tns:execute_ptt">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="execute">
            <soap:operation style="document"
                            soapAction="http://xmlns.oracle.com/SOAApplication/ExposeWithHeaderProject/BPELProcess1/execute"/>
            <wsdl:input>
               <soap:header message="tns:requestMessage" use="literal" part="header"/>
                <soap:body use="literal" parts="payload"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" parts="payload"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
</wsdl:definitions>

 Deploy and take the wsdl and test from soap ui
 See 2 parts created one for Input and another for header.
Note: with Oneway /Async BPEL service, you can't expose the service with headers.

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