Friday, July 24, 2015

Dynamic Endpoint Url Invocation in BPEL

Hi,

I would like to share how to dynamically call a Web Service through BPEL using Endpoint Reference.

Firstly lets understand what use the Dynamic Endpoint Invocation could be. In scenarios where you have a good number of Services whose consumption parameters are same, ie input-output, to avoid code multiplication, we use DEI. Else a developer would end up creating as many partner links as the number of isomorphic services exists.

image : msdn.microsoft.com




First of all, you need to have the URL generated at runtime either through DVM / any source service request/ Database/ MDS etc.

In BPEL, assign the URL to a variable say ServiceToInvokeVar


ex:
 1
<assign name="Set_ServiceToInvokeVar">
      <copy>
        <from variable="inputVariable" part="payload"
              query="/ns3:******/ns3:*******/ns3:AbcsEndPointUrl"/>
        <to variable="ServiceToInvokeVar"/>
      </copy>
    </assign>
2
 <assign name="Assign_Endpoint">
      <copy>
        <from>
<EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing">
            <Address/>

 </EndpointReference>
</from>
        <to variable="EndpointReferenceVar" query="/ns1:EndpointReference"/>
      </copy>
      <copy>
        <from variable="ServiceToInvokeVar"/>
        <to variable="EndpointReferenceVar"
            query="/ns1:EndpointReference/ns1:Address"/>
      </copy>
      <copy>
        <from variable="EndpointReferenceVar"/>
        <to partnerLink="ABCSService"/>
      </copy>

    </assign>


If the above seems complicated to you, here I can explain here,

1. Assigned your runtime populated Endpoint to a variable say X.
2. Assign the EndpointReference WS-Addressing structure to a variable say E with null address.
3. Assign X to "/ns1:EndpointReference/ns1:Address"
4. Assign  E to your partner link.

Thats it !

1 comment: