Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c

================================================================================================

Set Composite Instance Name in Mediator or BPEL

You can set the Composite Instance Name that appears in the Name column in EM Instances screen.

This could be done either in the Mediator or in BPEL Component

In Mediator

In the Routing Rule 'Assign Values' section, you need to set the Composite Instance Title.



Set the value you want to display in the Name column of EM using the function setCompositeInstanceTitle('Name to be displayed') to the property 'tracking.compositeInstanceTitle'. This property is not available by default, just type it.

Namespace of the function will be 'http://schemas.oracle.com/mediator/xpath'

Here is the XML generated, you can check the namespace if the default generated one causes problems

<!-- START -->
<assign>
                  <copy target="$out.property.tracking.compositeInstanceTitle"
                        expression="med:setCompositeInstanceTitle(concat('CREATE GROUP ESN :: ',$in.parameters/xsd1:createRequest/xsd1:gpInfo/xsd1:masterESN))"
                        xmlns:xsd1="http://www.soatutor.com/MyServices"
                        xmlns:med="http://schemas.oracle.com/mediator/xpath"/>
               </assign>
<!-- FINISH -->

In BPEL
Use the function
ora:setCompositeInstanceTitle and set it to any temporary variable in the BPEL Process, and the process will set the Composite Instance Title.


Namespace : xmlns:ora="http://schemas.oracle.com/xpath/extension"

Here is the sample XML generated

<!-- START -->
<copy>
            <from expression="ora:setCompositeInstanceTitle(concat(&quot;Failed :: &quot;,bpws:getVariableData('errorOperation')))"/>
            <to variable="title"/>
          </copy>
<!-- FINISH -->

Assign the whole input to a variable

Sometimes, you need to log the whole request to a log table for error tracking. In such cases, you can use the function

oraext:get-content-as-string(bpws:getVariableData('inputVariable','redeemRequest','/ns2:redeemRequest'))

XSL for splitting CSV into seperate nodes

Input

<varForCSVComplexType>
 <IndActivityPayload xmlns="http://www.example.org">
  <PlannedFinishDate/>
  <AttachmentLoc>406,405,401</AttachmentLoc>
  <reviewerApproval/>
  <reviewerComments/>
 </IndActivityPayload>
</varForCSVComplexType>

Required Output

<ArrayOfUCMDocIds xmlns:ns0="http://www.example.org" xmlns="http://www.example.org">
<ns0:indDocId>406</ns0:indDocId>
<ns0:indDocId>405</ns0:indDocId>
<ns0:indDocId>401</ns0:indDocId>
</ArrayOfUCMDocIds

XSLT : Kind of recurrent call till there are no comma(',')

<xsl:stylesheet version="1.0"
                xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
                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.example.org"
                xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
                xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:med="http://schemas.oracle.com/mediator/xpath"
                xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
                xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
                xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:bpmn="http://schemas.oracle.com/bpm/xpath"
                xmlns:ora="http://schemas.oracle.com/xpath/extension"
                xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
                xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
                exclude-result-prefixes="xsi xsl ns0 xsd bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref bpmn ora socket ldap">

 <xsl:strip-space elements="*"/>
 <xsl:template match="/ns0:IndActivityPayload/ns0:AttachmentLoc">
  <ns0:IndActivityPayload>
    <xsl:apply-templates/>
  </ns0:IndActivityPayload>
 </xsl:template>

 <xsl:template match="text()" name="split">
  <xsl:param name="pText" select="."/>
  <xsl:param name="pItemElementName" select="'ns0:AttachmentLoc'"/>
 
    <xsl:if test="string-length($pText) > 0">
     <!-- Below declaration basically concatenates a ',' to the value just in case we have only one element and if there is no comma, then the value just returns nothing -->
     <xsl:variable name="vNextItem" select="substring-before(concat($pText, ','), ',')"/>
     <ns0:indDocId>
        <xsl:value-of select="$vNextItem"/>
      </ns0:indDocId>
      <xsl:call-template name="split">
        <xsl:with-param name="pText" select="substring-after($pText, ',')"/>
        <xsl:with-param name="pItemElementName" select="$pItemElementName"/>
      </xsl:call-template>
    </xsl:if>
 </xsl:template>
</xsl:stylesheet>

Caused by javax.resource.spi.InvalidPropertyException: Missing Property Exception. Missing Property: [ConnectionFactory> xADataSourceName or dataSourceName].

Exception Trace

com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.oracle.com/bpel/extension}bindingFault}
messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage}
parts: {{
summary=<summary>Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'GetAccountInfoDS' failed due to: Could not create/access the TopLink Session.
This session is used to connect to the datastore.
Caused by javax.resource.spi.InvalidPropertyException: Missing Property Exception.
Missing Property: [ConnectionFactory> xADataSourceName or dataSourceName].
You may have set a property (in _db.jca) which requires another property to be set also.
 Make sure the property is set in the interaction (activation) spec by editing its definition in _db.jca.
.
You may need to configure the connection settings in the deployment descriptor (i.e. DbAdapter.rar#META-INF/weblogic-ra.xml) and restart the server.  This exception is considered not retriable, likely due to a modelling mistake.
". 
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</summary>
,detail=<detail>Missing Property Exception.
Missing Property: [ConnectionFactory> xADataSourceName or dataSourceName].
You may have set a property (in _db.jca) which requires another property to be set also.
 Make sure the property is set in the interaction (activation) spec by editing its definition in _db.jca.
</detail>
,code=<code>null</code>

When you get this while trying to connect to the database from a DatabaseAdapter, solution as follows

Solution :
Assuming you had already created the datasource & Outbound Connection Pool for the DatabaseAdapter,
Goto deployments --> dbAdapter --> check it & click on 'Update' --> Redeploy.
This should fix the issue. If not, restart and it should fix now.

XSLT : Duration between 2 Dates

XSLT 2.0 lets you calculate the date difference very easily.

My Input is as below

<?xml version="1.0" encoding="UTF-8" ?>
<input xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.example.org">
   <benefitsDeliveryServiceEndDate>2015-02-11-05:00</benefitsDeliveryServiceEndDate>
   <cboNextChargeDate><![CDATA[2015-12-11]]></cboNextChargeDate>
</input>

One thing to make sure is that the formats has to be the same. If the date formats are different, then make them into the same either using xp20:format-dateTime or using substrings.

Here is the xslt that calculates the duration b/w the two dates. I'm trimming the result to get only the number of days, you can do as per your requirement.

<xsl:stylesheet version="2.0"
                xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
                xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:ns0="http://www.example.org"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
  <xsl:template match="/">
    <ns0:dateDiff>
      <ns0:daysToBump>
        <xsl:variable name="bfDlvServEndDate" select="/ns0:input/ns0:benefitsDeliveryServiceEndDate"/>
        <xsl:variable name="cboServiceDate" select="/ns0:input/ns0:cboNextChargeDate"/>
            <!--<xsl:variable name="currentDate" select="xp20:current-date()"/>-->

            <!-- DateDifference Calculation -->
            <xsl:variable name="daysToBump" select="(xsd:date($bfDlvServEndDate) - xsd:date($cboServiceDate))"/>
            <!-- Convert date to string so that you can trim to get the Date -->
            <xsl:variable name="daysToBump" select="xsd:string($daysToBump)"/>
            <xsl:choose>
                <xsl:when test="contains($daysToBump,'D')">
                    <xsl:value-of select="substring-before(substring-after(xsd:string($daysToBump),'P'),'D')"/>
                </xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
      </ns0:daysToBump>
    </ns0:dateDiff>
  </xsl:template>
</xsl:stylesheet>

Will give the following result

<?xml version = '1.0' encoding = 'UTF-8'?>
<ns0:dateDiff xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://www.example.org" xsi:schemaLocation="http://www.example.org file:/C:/JDeveloper/mywork/SampleSOAApps/Project1/xsl/untitled1.xsd">
   <ns0:daysToBump>302</ns0:daysToBump>
</ns0:dateDiff>

java.lang.NullPointerException in BPEL Invoke

You might get the following error while invoking a service from BPEL

<bpelFault>
   <faultType>0</faultType>
   <remoteFault>
      <part name="summary">
         <summary>java.lang.NullPointerException</summary>
      </part>
      <part name="detail">
         <detail>null</detail>
      </part>
   </remoteFault>
</bpelFault>

This means that the service is not available, or atleast the bpel is not able to find the service operation.

But you might observe the service works fine directly.
This happens when the WSDL in the MDS is not updated with the right one (In my case, the service that I'm invoking is an OSB Service in some other machine)

Sometimes, the MDS doesn't get properly updated during the deployment. To confirm, create an MDS connection in JDev and check if the wsdl/xsd's are updated.

If not, then refresh the MDS / clear cache, and redeploy. It works now.