Thursday, 22 December 2011

How to set security credentials dynamically in Oracle BPEL

Few months ago I have written a post on invoking WS-Security compliant services, In Oracle BPEL you can either propagate the security credentials coming from the caller process or you can hard-code the tokens in partner link properties.
If you want to invoke a WS-Security compliant web service and want to pass user supplied security tokens, Oracle BPEL does not let you set the security credential dynamically. You need to manually create a UserNameToken and then you need to pass the token as a SOAP header.
Follow the steps given below to change and pass security credentials dynamically:
  • Create 3 variable as given below:
<variable name="securityContext" element="ns2:Security"/>
<variable name="userNameToken" element="ns2:UsernameToken"/>
<variable name="pswd" element="ns2:Password"/>
  • Assign incoming security credentials to these variables:
<assign name="AssignSecurityCredentials">
<from variable="inputVariable" part="payload"
<to variable="pswd" query="/wsse:Password"/>
<from variable="inputVariable" part="payload"
<to variable="userNameToken"
<bpelx:from variable="pswd" query="/wsse:Password"/>
<bpelx:to variable="userNameToken"
<bpelx:from variable="userNameToken" query="/wsse:UsernameToken"/>
<bpelx:to variable="securityContext" query="/wsse:Security"/>
  • Pass the security credentials to the calling service like the expression given below:
<invoke name="InvokeAxisService" partnerLink="PartnerLinkAxisService"
portType="ns1:sample03PortType" operation="echo"
Complete you BPEL process by adding required functionalities then deploy and test it.

1 comment:

  1. do we need to use the securityContex in WSDL?