Friday 17 November 2017

SOA 12c BPEL : Invoke Partner Service using SOAP Header

If you have to invoke a partner service which requires username and password to be populated in the SOAP Header custom elements you can follow the below steps as I did.

Before we come to the BPEL part, validate the custom elements that should be part of the schema definition and WSDL binding:

1. Your target service schema will have a header element like below:

<schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Header">
     <complexType>
        <sequence>
            <element name="username" type="string"/>
            <element
name="password" type="string"/>
         </sequence>
     </complexType>
</element>
</schema>


2. In the target service WSDL below declaration should be made

a. Message: (check your namespace and edit accordingly below)

<message name="InputHeaderMessage">
    <part
name="header" element="tns:header"/>
</message>


b. Binding:

<binding name="HeaderTest" type="tns:HeaderTest">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation
name="process">
<soap:operation style=document soapAction="http://xmlns.oracle.com/HeaderTestApp/HeaderTestBPEL"/>

  <input>
    <soap:header message="tns:InputHeaderMessage" part="header" use="literal"/>
    <soap:body parts="payload" use="literal"/>
  </input>
</operation>
</binding>


3. Create 2 preference variables in composite.xml

    <property name="bpel.preference.username">test</property>
    <property
name="bpel.preference.password">test1</property>

4. Now coming to BPEL, we will first create a variable varHeader of type Element and select the header element from the schema.

5. Add Assign activity in BPEL and assign the preference value to the variables username and password.

    ora:getPreference("username") - $varHeader.username
    ora:getPreference("password") - $varHeader.password

6. Add Invoke activity below, connect to the target partnerLink.
7. Open the invoke activity, click on Header tab and select the variable varHeader

          

8. Save, Deploy and Test.


Helpful? Please Comment.

Happy Learning!!

No comments:

Post a Comment

OSB 12c : Dynamic Routing to Business/Proxy Service

Dynamic routing is a kind of  Content-based Routing pattern, which is used when the BusinessService/ProxyService path is required to be de...