Monday, May 26, 2014

Set & Send SOAP Headers in BPEL

Recently, I am supposed to call a external web service and it require few values in SOAP header to validate the request message. I did following changes in my BPEL process to set & send SOAP headers in request message.

Request Message Format:
<soapenv:Envelope xmlns:soapenv="">
<ns2:UsernameToken xmlns:ns2="">LK@XYZ.COM</ns2:UsernameToken>
<ns3:PasswordText xmlns:ns3="">Test123</ns3:PasswordText>
      <..........................SOAP BODY..............>

I followed below steps to set these headers in BPEL.

  • Created a XSD having required headers as elements in schema. For ex:

            <?xml version="1.0" encoding="UTF-8" ?>
           <xsd:schema xmlns:xsd=""
              <xsd:element name="UsernameToken" type="xsd:string"/>
              <xsd:element name="PasswordText" type="xsd:string"/>

  • In BPEL process created a two variables based on above schema to hold header values.

           <variable name="UsernameToken" element="ns2:UsernameToken"/>
           <variable name="PasswordText" element="ns2:PasswordText"/>

  • Assigned values for these variables using assign activity.

         <assign name="AssignInput">
                <from expression="'LK@XYZ.COM'"/>
                <to variable="UsernameToken" query="/ns2:UsernameToken"/>
               <from expression="'Test123'"/>
               <to variable="PasswordText" query="/ns2:PasswordText"/>

  • Set these variables as Headers in Invoke activity. The Invoke activity looks as below, after adding headers.

          <invoke name="InvokeWS"
            outputVariable="WS_OutputVariable" partnerLink="TestWebService"
            portType="ns1:AutoRequest" operation="process"

No comments:

Post a Comment

Provide your thoughts !