Tags

Today the BPEL there is no specific function for us to work directly with Regex (Regular Expression) in BPEL, so I will demonstrate this Post one of the ways we can do to apply a Regex to a process.

In this example we will basically pass a value to our BPEL and will validate these values through the Regex.

For our tests create a project called RegexBpel

Imagem Blog UansCarvalho

Within our Composite.xml add a BPEL Process called RegexBPELProcess

Imagem Blog UansCarvalho

Within your RegexBPELProcess add a Transformation and name it Transform_Regex

Imagem Blog UansCarvalho

Now double-click on your Transform_Regex

In Source add your inputVariable and in Target Variable let your outputVariable and click the + sign to open up the Transformation.

Imagem Blog UansCarvalho

Now connect your input with your result.

Imagem Blog UansCarvalho

Now go in your Source Transformation and add the following line in the declaration of their namespaces.

xmlns:strClass=”http://www.oracle.com/XSL/Transform/java/java.lang.String”

Imagem Blog UansCarvalho

Now add the code snippet below its <xsl:value-of select=”/client:process/client:input”/>

<xsl:call-template name=”strReplace”>
        <xsl:with-param name=”param” select=”/client:process/client:input”/>
</xsl:call-template>

Now pull your line <xsl:value-of select=”/client:process/client:input”/>

Then looks like this:

Imagem Blog UansCarvalho

Now add the code snippet below its </xsl:template>

<xsl:template name=”strReplace”>
    <xsl:param name=”param”/>
    <xsl:value-of select=”strClass:replaceAll($param, ‘[^0-9]’, ”)”/>
</xsl:template>

Imagem Blog UansCarvalho

See above we are using the replaceAll function, we will take what will be spent on our Input via the variable $param, we will apply the regex [^ 0-9] which will not be allowed to pass any value that is different from the range of numbers from 0 to 9 and finally through the single quotes, say that if there is these values will exchange for nothing, that is, will only pull these values.

Do you now deploy your project and let the tests

Direct in EM (Enterprise Manager) of your BPEL see below I’m going through values

A-1-2%3*4=5

Imagem Blog UansCarvalho

Run and see the Response return:

Imagem Blog UansCarvalho

See that in my response was withdrawn any amount spent different numbers.

 

Doubts ? Leave your comment and download this  Projet :-)

Hugs and see you next

/:-D