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.

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