Dynamic Partner Link with BPEL 2.0 and SOA Suite 12.2.1.3

Problem: Calling the external soap services dynamically using BPEL 2.0.

Issues Fixed:

<selectionFailure xmlns=”h ttp://docs.oasis-open.org/wsbpel/2.0/process/executable”>

<part name=”summary”>

<summary>fromValue is not a sref:service-ref element</summary>

</part>

Prerequisites:

  1. Multiple SOAP services with same port type, binding and different endpoints.
  2. Provision to store or access the external soap service endpoint urls. In my case I am storing end point urls in DB table

Note: For Dynamic partner link in BPEL 1.0 refer https://manoharsr.wordpress.com/2013/04/02/dynamic-partner-link-in-bpel/

Step1: Creating BPEL SOAP service which can be used as reference.

  • Create a SOA project
  • Create a abstract wsdl which will be used to create a bpel service based on wsdl.

  • Create a bpel based on the above abstract wsdl and implement required business logic
  • Deploy the project
  • Repeat step 1 for required no of soap services

Step 2. Create SOA Project with name DynamicServiceCallPrj through which we will call the external web service dynamically

  • Create a BPEL process and expose as a webservice through which we can test. In my case DB Pool service for scheduling which can be ignored
  • Create a DB reference to get the external web service end point url from the table
  • Create a SOAP reference using one of the external web service endpoint url. This will create a the partner link when wired to bpel and can be updated with dynamic urls at the runtime

  • Create a 2 xsd files as ws-addressing.xsd and ws-bpel-serviceref.xsd


  • Create a xsd element as below any user defined xsd

    <element name=”RefURL”>

    <complexType>

    <sequence>

    <element name=”URL” type=”string”/>

    </sequence>

    </complexType>

    </element>

  • Create 2 variable as following
  1. serviceRef based on service-ref element in ws-bpel_serviceref.xsd

  2. url based on the RefURL element specified above

  • Create a for loop to iterate db records
  • Add an assign activity to pass the input data to external service
  • Add assign activity to retrieve the endpoint url from each record in the loop and assign it the url variable

  • Create a xslt transform with url variable as source and serviceRef as target variable

  • Add the following in the XSLT.

    <tns:service-ref>

    <EndpointReference xmlns=”http://schemas.xmlsoap.org/ws/2004/08/addressing”&gt;

    <Address>

    <xsl:value-of select=”/ns0:RefURL/ns0:URL”/>

    </Address>

    </EndpointReference>

    </tns:service-ref>

    Very Important

    In the XSLT make sure the namespace are as below

    service-ref element as xmlns:tns=http://docs.oasis-open.org/wsbpel/2.0/serviceref

    EndpointReference element as xmlns=http://schemas.xmlsoap.org/ws/2004/08/addressing

  • Assign the serviceRef to the SOAPReference partnerlink

  • Finally your BPEL looks as the below

Step3: Deploy the project and test service.

One response

  1. Thanks Manohar. It works perfectly. Only thing I noticed is, even if the wsdl that we call has any issues, it doesn’t throw an exception in this method. Is there anything we need to do?

Leave a comment