Monday, February 24, 2020

12c SOA - DVM - lookup multiple domain values

Here I will show you how to get multiple domain values from a DVM using dvm:lookupValue1M() function.

Implementation steps:
Create a SOA Project


 Select Empty composite
 Create the contract schema which is used for exposing the client.



 <?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.citydetails.poc"
            targetNamespace="http://www.citydetails.poc" elementFormDefault="qualified">
  <xsd:element name="clientRequest">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="cityName" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="clientResponse">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="cityName" type="xsd:string"/>
        <xsd:element name="cityCode" type="xsd:string"/>
        <xsd:element name="state" type="xsd:string"/>
        <xsd:element name="capital" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema> 

Create WSDL based on this schema.



 Take a BPEL Process and select based on wsdl template and choose the created the wsdl.




 Create a City DVM



 In the BPEL, Drag and drop Transformation activity and use dvm:lookupValue1M() function to get multiple values and store them in a variable and then use the variable in fields mapping.

We use dvm:lookupValue and dvm:lookupValue1M XPath functions to look up a domain value map for a single value or multiple values at runtime from DVM tables. Here I have used the dvm:lookupValue1M Xpath function in XSL to get the city detail by passing CityName as a KeyColumn to lookup dvm table.

XSLT:
 <?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator" xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas" xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue" xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction" xmlns:oraxsl="http://www.oracle.com/XSL/Transform/java" xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.citydetails.poc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions" exclude-result-prefixes=" oracle-xsl-mapper xsi xsd xsl ns0 socket dvm mhdr oraxsl oraext xp20 xref"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                xmlns:tns="http://xmlns.oracle.com/SOAApplication/DVM1ToManyProject/cityDetails">
   <oracle-xsl-mapper:schema>
      <!--SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY.-->
      <oracle-xsl-mapper:mapSources>
         <oracle-xsl-mapper:source type="WSDL">
            <oracle-xsl-mapper:schema location="../WSDLs/cityDetails.wsdl"/>
            <oracle-xsl-mapper:rootElement name="clientRequest" namespace="http://www.citydetails.poc"/>
         </oracle-xsl-mapper:source>
      </oracle-xsl-mapper:mapSources>
      <oracle-xsl-mapper:mapTargets>
         <oracle-xsl-mapper:target type="WSDL">
            <oracle-xsl-mapper:schema location="../WSDLs/cityDetails.wsdl"/>
            <oracle-xsl-mapper:rootElement name="clientResponse" namespace="http://www.citydetails.poc"/>
         </oracle-xsl-mapper:target>
      </oracle-xsl-mapper:mapTargets>
      <!--GENERATED BY ORACLE XSL MAPPER 12.2.1.0.0(XSLT Build 151013.0700.0085) AT [MON FEB 17 13:56:32 IST 2020].-->
   </oracle-xsl-mapper:schema>
   <!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE-->
    <xsl:variable name="CityDetails"
   select="dvm:lookupValue1M('DVM/CityDetails.dvm','CityName',/ns0:clientRequest/ns0:cityName,'CityCode','State','Capital')"/>
   <xsl:template match="/">
      <ns0:clientResponse>
         <ns0:cityName>
            <xsl:value-of select="/ns0:clientRequest/ns0:cityName"/>
         </ns0:cityName>
         <ns0:cityCode>
            <xsl:value-of select="$CityDetails/CityCode"/>
         </ns0:cityCode>
         <ns0:state>
            <xsl:value-of select="$CityDetails/State"/>
         </ns0:state>
         <ns0:capital>
            <xsl:value-of select="$CityDetails/Capital"/>
         </ns0:capital>
      </ns0:clientResponse>
     
   </xsl:template>
</xsl:stylesheet>
 Deploy and test


No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...