The example detailed below uses the the country code in the input payload (in my example, stored in /imp1:Datas/imp1:Data/imp1:Application) to lookup the actual endpoint. The XSL mapper file will perform a DVM lookup via the orcl:lookup-dvm function, and store the result in the outbound header via the ehdr:setOutboundHeader function. The ehdr:setOutboundHeader function overrides the actual endpoint of the external SOAP service. As a result, although you have one external SOAP service defined in your ESB project, it can be overriden at runtime.
Step 1: Create a DVM
Create a DVM manually, or import the following XML through ESB Control:
<?xml version = '1.0' encoding = 'UTF-8'?> <dvm name="Endpoints" isNew="null"> <description>Dynamic endpoints for all systems</description> <columns> <column name="System"/> <column name="Endpoint"/> </columns> <rows> <row><cell>US</cell><cell>http://usaserver.itconvergence.com:7777/createCustomer</cell></row> <row><cell>EU</cell><cell>http://europeserver.itconvergence.com:80/createCustomer</cell></row> <row><cell>SA</cell><cell>http://southamericaserver.itconvergence.com/createCustomer</cell></row> </rows> </dvm> |
Step 2: Create the ESB service
Create a simple ESB service consisting of:
- Inbound file adapter
- Routing service
- Outbound SOAP service
Only one outbound external SOAP service is required, even though there are actually several endpoints. The WSDL of this SOAP service may have a hardcoded SOAP address location of any one of the external services. For example:
- <soap:address location="http://southamericaserver.itconvergence.com/createCustomer"/>
Step 3: Create mapper file
Create a new mapper file (i.e., XSL transformation) between the routing service and the SOAP service.
Step 4: Transform the outbound header
Utilize the header transformation extension function setOutboundHeader to update the outbound header and override the SOAP address location that is hardcoded in the WSDL. Click on "Source" to view the source of your XSL file just created, and immediately before the statement <xsl:template match="/">, add the following:
<xsl:variable name="LocationIn" select="orcl:lookup-dvm('Endpoints', 'System', /imp1:Datas/imp1:Data/imp1:Application, 'Endpoint','')"/> <xsl:variable name="LocationOut" select="ehdr:setOutboundHeader('/shdr:ESBHeader/shdr:location', $LocationIn, 'shdr=http://xmlns.oracle.com/esb;')"/> |
That's it!
2 comments:
Hi Ahmed,
Thank you very much for the wonderfull blog, You have done provided us with solution for most of the problem on Oracle10gR3.
keep it up.
Thanks and Regards
NK
Good Post
Thanks,
Bala
Post a Comment