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.

Thursday, February 6, 2020

12c SOA - Composites - Unit Test suites creation and run the test cases from console.

Topics covered:
  • Create, deploy, and run test cases that automate the testing of SOA composite applications.
Why Test Suites:
Test cases enable you to simulate the interaction between a SOA composite application and its web service partners before deployment in a production environment. This helps to ensure that a process interacts with web service partners as expected when it is ready for deployment to a production environment.

In this type of testing, wires, service binding components, service components (such as BPEL processes and Oracle Mediator service components), and reference binding components are tested.

Overview of Test Suites
Test suites consist of a logical collection of one or more test cases. Each test case contains a set of commands to perform as the test instance is executed. The execution of a test suite is known as a test run. 

Before starting let me explain you two basic terms that will be used while creating test cases. These are 
Assertions : You perform assertions to verify variable data or process flow. Assertions enable you to validate test data in an entire XML document as a process is executed. This is done by extracting a value and comparing it to an expected value.
Emulations: These are used to simulate the message data that your SOA composite application receives from web service partners.

Usecase:
I have created a sample SOA application having BPEL service exposed as web service and wired with DB adapter which is used to call a table that I have created.The input for this interface is a string variable and its value would be passed to the table as an input parameter by our BPEL process.In response it will return response based upon the input passed. Visit my previous blog for the steps 12c-soa-db-adapter-perform-select.

Below is the list of input and output that would be returned:
Input: EmpId
Output: EmpId EmpFName EmpFName DeptId DeptName EmpType

Test cases tested with the implementation:
  • Case1 -Tested with initiate Message + Assert Input to BPEL + Assert Input and output DB Adapter. Result: It will fetch the data from the DB table based on the assigned Input in the test case and validate with the assert output data. if they are matched, then it is passed with success. otherwise it is failed.
  • Case2 - Tested with initiate Message +  Assert Input to DB Adapter. Result: It will fetch the data from the DB table based on the assigned Input in the test case.
  • Case3 - Tested with initiate Message + Assert Input to BPEL + Emulate Output to DB Adapter. Result: It will fetch the data from the DB table based on the assigned Input in the test case. if Input is dummy or invalid, then it will send the emulate data as a output to the user.
Implementation:
In project explorer⇾navigate to "testsuites" then right click and click on "Create Test Suite".
 Give the test suite name and click ok.
 Another window will open up prompting for test case name.Give the test case name and click OK.
 Next
Input  Initiate Message - Generate Sample
 Provide the data.
 Test Output part - Generate Sample
 Provide the output data
 So the Test case is ready.
Deploy and run Test case 1 :






Now use only Initiate Input and Assert Input to the Adapter

 Deploy and run Test case 2 :
Now use Initiate Message + Assert Input to Adapter + Emulate Output from the adapter.





 Deploy and run Test case 3 :


In this way we can add any number of test cases to our SOA composite application and before deploying them to production we can test our composites functionality whether they are behaving in expecting manner or not.

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