Wednesday, September 22, 2010

Using Dynamic Endpoint for a non-AIA based Composite in SOA 11g

The use of dynamic endpoint approach for a non-AIA based Composite is more or less the same, as it would have to been done for an AIA Composite. The stress on AIA in the implementation of dynamic endpoint is because AIA has AIAConfigurations.properties file, where usually this type information is stored. This information can be changed, loaded and reference at runtime, and so making the endpoint dynamic. The non-existence of AIA does not limit one from implementing this.

One just needs to make sure, AIA is replaced by a suitable component. By this statement, I mean one needs to make sure a mechanism is available to change, load and reference the endpoint at runtime. Oracle Fusion Middleware offers a lot of option for one to replace AIA. You can do any one of the below and yet use the dynamic endpoint feature without AIA:
  • Store information in a file and use file adapter to read the file whenever required
  • Store information in a database table and use a DB adapter to fetch the information
  • Use BPEL Preference Properties to store the information (Preference Properties can be modified at runtime from EM Console)
  • Store the information in Domain Value Map (DVM) and use functions to read the information from DVM
In all the cases, the information can be modified on the fly and each have their own set of limitations. I  saw DVM as the simplest, straightforward, hassle-free and readymade approach towards dynamic endpoint.

I created a DVM to store the information: Name of the Composite and Endpoint URI for the Composite. Teh DVM can be created within the Composite or deployed to MDS directly and referred from MDS. As to, how to deploy the DVM to MDS and referring from MDS, read this post.

Implementing the Dynamic Endpoint:

Creating Variables in BPEL:

  1. Create two variables in the BPEL flow namely, TargetEndpointLocation (String) and EndpointReference (of Type EndpointReference from WS-Addressing)
  2. When creating  the variable EndpointReference, import the XSD ws_addressing.xsd and choose the element type EndpointReference to create the variable
  3. ws_addressing.xsd can be downloaded from here
  4. This way, one need not copy-paste any code, or insert any namespace in the BPEL Process and its corresponding WSDL 
  5. After creating the variables, open the .bpel in source  mode and look for the namespace http://schemas.xmlsoap.org/ws/2003/03/addressing. Change the namespace prefix to wsa so that the namespace looks like below:
     xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"
Implementing the dynamic endpoint:

  1. Use the dvm:lookupValue function to look up the endpoint URI from the DVM. In the code snippet below, I have the DVM in MDS and I am looking up a DVM by name Endpoints to get the endpoint URI
  2. Assign the URI to /wsa:EndpointReference/wsa:Address
  3. Assign the /wsa:EndpointReference/wsa:Address to Partner link in the invoke that follows this logic
  4. Insert the below code snippet just before the invoke node from the source view of the .bpel

Code Snippet:

<scope name="Scope_GetDynamicEndpoint">
    <sequence>
        <assign name="Assign_targetEndpointLocation">
            <copy>
                <from expression="dvm:lookupValue('oramds:/apps/Samples/Endpoints.dvm','ServiceName','SampleFlow','EndPoint','')"/>
                <to variable="TargetEndpointLocation"/>
            </copy>
        </assign>
        <assign name="AssignPartnerlinkEndpointReference">
            <copy>
                <from>
                    <wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing">
                        <wsa:Address/>
                    </wsa:EndpointReference>
                </from>
                <to variable="EndpointReference" query="/wsa:EndpointReference"/>
            </copy>
            <copy>
                <from variable="TargetEndpointLocation"/>
                <to variable="EndpointReference"
                query="/wsa:EndpointReference/wsa:Address"/>
            </copy>
            <copy>
                <from variable="EndpointReference"/>
                <to partnerLink="SampleFlowTarget"/>
            </copy>
        </assign>
    </sequence>
</scope>

    inputVariable="Invoke_SampleFlowTarget_InputVariable"
    ......



Peace!

Cheers,
- AR

2 comments:

shy said...

Thanks for the post. I would like to know what is the difference between using the end point from DVM and referencing wsdl end point from mds itself. I have never used the DVM, but used the wsdl reference from MDS and find that easier. But would like to know what would be the difference. Thanks.
Sonya Krishna

shy said...
This comment has been removed by the author.
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License