Thursday 17 April 2014

Remove xsi:nil="true" from your XML along with the Null Tags

Suppose I am getting a XML like this..

<ebs:ShopFloorInputParameters xmlns:ebs="http://xmlns.abcd.com/EBSShopFloorSyncProvABCSImpl">
   <ValidateShopFloorRequest>
       <OrgCode xsi:nil="true">CH112A</OrgCode>
      <MFGType xsi:nil="true">FLOW12</MFGType>
      <ScheduleNum xsi:nil="true">1175007</ScheduleNum>
      <LineId xsi:nil="true"></LineId>
      <LineOP xsi:nil="true"></LineOP>

<ValidateShopFloorRequest>
</ebs:ShopFloorInputParameters>


No I want to remove all emty tags and also xsi:nil from my elements. I just have to use the below XSLT (source variable and target variable will be same the one which is carrying the XML)

<?xml version='1.0' encoding='UTF-8'?>
<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: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: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 bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref ora socket ldap">

  <xsl:template match="node()">
  
      <xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0])">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:if>
  </xsl:template>

  <xsl:template match="text()">
    <xsl:value-of select="."/>
  </xsl:template>
</xsl:stylesheet>



Target XML :


<ebs:ShopFloorInputParameters xmlns:ebs="http://xmlns.abcd.com/EBSShopFloorSyncProvABCSImpl">
<ValidateShopFloorRequest>
<OrgCode>CH112A</OrgCode>
<MFGType>FLOW12</MFGType>
<ScheduleNum>1175007</ScheduleNum>

<ValidateShopFloorRequest>
</ebs:ShopFloorInputParameters>

Tuesday 27 August 2013

How to Enable jms/b2b/B2B_OUT_QUEUE before You are Using B2B Adapter in Your SOA Composite

To retrieve messages from B2B_OUT_QUEUE we have enable the ‘Use JMS Queue as default’ as true from B2B console > Administration >configuration…


Wednesday 19 June 2013

DB Polling Issue faced for SYBASE database


Distributed polling mechanism is used when a DB poller process is deployed in an active/active cluster environment. In that case a deployed process will have two instances of process polling on the same table. Distributed polling techniques can be used for inbound Database Adapters to ensure that the same data is not retrieved more than once.

For a typical DB adapter polling from oracle database table, it is very easy to add distributed polling mechanism by just checking Distributed polling check box in the adapter creation wizard.





But when a DB adapter is polling from a sybase database table, the same configuration will not work and we might face issue like the same record is polled twice in an active-active cluster environment. To work distributed polling for a sybase database poller properly we will need to add few additional steps as part of the adapter configuration. Below are the steps to apply distributed polling for a sybase database adapter…


1.   Before configuring the database adapter go to the connection factory settings from console->Deployments->DbAdapter->Configuration->Outbound Connection Pool.
Click on your connection factory which is using the Sybase data source and change the platformClassName value to org.eclipse.persistence.platform.database.DatabasePlatform.
Save and active changes.
2.    Now go to the adapter configuration wizard. In the page where we select the column name and read/unread value set Resereved value as R${weblogic.Name-2}-${IP-2}-${instance}


1.    Go to next page and check distributed polling check box. We will see a new pre poling SQL is generated this time. Click next and finish the adapter configuration wizard…


Now the polling process can be deployed and tested in a cluster environment.

Note: The read column (RequestStatusCd in above example) should have the column length to take reserved value (R${weblogic.Name-2}-${IP-2}-${instance}) which may vary from one environment to another.



Sunday 12 June 2011

Adding Custom Xpath function in BPEL

1. Introduction :
Below steps will provide the way to add custom xpath function in your BPEL Code. In the below example we will create a custom xpath function which will take a string as an input from the BPEL code and will return “string + ‘is good’” as an output.

2. Creating the java application

Create a java application which will implement IXPATHFunction class and perform the required string operation. Below is the source code :

package com.bpelsoa.xpath;

import com.collaxa.cube.xml.dom.DOMUtil;
import com.oracle.bpel.xml.xpath.IXPathContext;
import com.oracle.bpel.xml.xpath.IXPathFunction;
import com.oracle.bpel.xml.xpath.XPathFunctionException;
import java.util.List;
import org.w3c.dom.Node;

public class ApplicationCustomXpathPOC implements IXPathFunction {

    private static final int NB_ARGS = 1;
    private static final int INDEX_ARG = 0;


/* below function called by the BPEL engine. */
    public Object call(IXPathContext context,
                       List args) throws XPathFunctionException {
        if (args.size() == NB_ARGS) {
            Object o = args.get(INDEX_ARG);
            String str = getValue(o);
            return concatIsGood(str);
            //return "test";
        }
        throw new XPathFunctionException("This function requires one argument.");

    }

    private String getValue(Object o) throws XPathFunctionException {
        if (o instanceof String) {
            return ((String)o);
        } else if (o instanceof Node) {
            return DOMUtil.getTextValue((Node)o);
        } else {
            throw new XPathFunctionException("Unknown argument type.");
        }
    }

    private String concatIsGood(String str) {
       /* for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return Boolean.FALSE;
            }
        }
        return Boolean.TRUE;*/
         //throw new javax.xml.xpath.XPathFunctionException("This function requires one argument.");
        
         String s= str + " is good";
         return s;
    }
}

3. Create the jar
Compile and create the jar from the java application following below steps…

i. Right click on the java project and click new…



ii. Go to deployment profiles and click on jar files…


iii. Give a proper deployment profile name (in the same name the jar will be created)



iv. Click ok on the next window…


iv.    The .deploy file will be created under the resource directory of the project…




iv.    Now right click on .deploy file and click deploy to jar file to create the jar.


Changes in xpath-function.xml
We need to add the new custom xpath function in the xpath-funtion.xml file which is under /aiaapp/oracle/product/10.1.3.1/OracleAS_1/bpel/system/config directory.

Below entry is made for the custom xpath function :

<function id="concatIsGood">
  <classname>com.bpelsoa.xpath.ApplicationCustomXpathPOC</classname>
  <comment><![CDATA[This implements a small tool which concats is good with any string given as an argument. The signature of this function is bpelsoa:concatIsGood(String).]]></comment>
  <property id="namespace-uri">
    <value>http://bpelsoa.blogspot.com</value>
    <comment>Namespace URI for this function</comment>
  </property>
  <property id="namespace-prefix">
    <value>custXpath</value>
    <comment>Namespace prefix for this function</comment>
  </property>
</function>

Put the jar in Server
Put the CustomXpathPOC.jar in server’s jar location (/aiaapp/oracle/product/10.1.3.1/OracleAS_1/bpel/libcox/) and make the corresponding entry in server.xml which is under /aiaapp/oracle/product/10.1.3.1/OracleAS_1/j2ee/oc4j_soa/config/. After this a restart the server.

Using your new custom xpath function in a BPEL process

A custom xpath function can be used as any xpath functions. It has to be in an expression field from an assign activity (copy, append, insert after/before, etc.).

Below is the code snippet…

<assign name="xpathCall">
      <copy>
        <from variable="inputVariable" part="payload"
              query="/client:POCForCustomXpathProcessRequest/client:input"/>
        <to variable="Str"/>
      </copy>
      <copy>
        <from expression="custXpath:concatIsGood(bpws:getVariableData('Str'))"/>
        <to variable="outputVariable" part="payload"
            query="/client:POCForCustomXpathProcessResponse/client:result"/>
      </copy>
    </assign>
 


Saturday 7 May 2011

Using key for apply templates in xsl

We can use key() function for apply-templates element also.
 Below is one example :

<xsl:param name="country_name"/>
                <xsl:key match="/ns1:POC_KeyProcessRequest/ns1:SupplierDetails/ns1:Details" name="Supplier_name_byCountry" use="ns1:Country"/>
  <xsl:template match="/">
  <ns1:POC_KeyProcessResponse>
      <ns1:Details>
      <xsl:apply-templates select="key('Supplier_name_byCountry',$country_name)"/>
      </ns1:Details>
      </ns1:POC_KeyProcessResponse>
  </xsl:template>
  <xsl:template match="/ns1:POC_KeyProcessRequest/ns1:SupplierDetails/ns1:Details">
  <ns1:name>
  <xsl:value-of select="./ns1:SupplierName"/>
  </ns1:name>
  </xsl:template>


This the source xml :

<POC_KeyProcessRequest xmlns="http://xmlns.oracle.com/POC_Key">
   <SupplierDetails>
      <Details>
         <SupplierName>Debdeep</SupplierName>
         <Country>india</Country>
         <Product>amway</Product>
      </Details>
      <Details>
         <SupplierName>mousumi</SupplierName>
         <Country>usa</Country>
         <Product>lakme</Product>
      </Details>
      <Details>
         <SupplierName>kajol</SupplierName>
         <Country>india</Country>
         <Product>bullet</Product>
      </Details>
   </SupplierDetails>
</POC_KeyProcessRequest>


And this is how the output looks like when param value for country_name was passed as india:

<ns1:POC_KeyProcessResponse xmlns:ns1="http://xmlns.oracle.com/POC_Key">
   <ns1:Details>
      <ns1:name>Debdeep</ns1:name>
      <ns1:name>kajol</ns1:name>
   </ns1:Details>
</ns1:POC_KeyProcessResponse>