Monday, October 23, 2017

XSLT how to handle XML and node set content in variables

It is very helpful to persist a xml node in a variable that we can query later using xpath, we can accomplish this easily, however you have to make sure the XML transformer (I use Xalan) you are using has to be compatible.

Having the following xml document to play around:

 This is article 1
 This is article 2
 This is article 3

1.- How to use a XSLT variable that holds a XPATH node set so we can use it as a variable in our XSLT.
1.1.- Build the variable using xpath and only get the node set that is required using a predicate
1.2.- Use the variable same way we use xpath expression Here is the xslt:
Here is the output:
Name: Article1
Desc: This is article 1

Notes: You might need to include this in the namespace depending on which transformer you are using:

This is an extension that allows to manipulate xml documents within a variable.

Friday, August 18, 2017

XSL left-right padding

Here is an example of howto accomplish padding situations:

For example if you want to right pad a 10 spaces string you can do:
 select="substring(concat($string, '          '), 1, 10))"/>

if you need a left pad you can change the order of the concat parameters as following:
 select="substring(concat('          ', $string), string-length($string)+1, 10))"/>

Now you can build a template function to call it.

Thursday, August 10, 2017

How to set a timeout for a Web Service Invocation/PartnetLink

Here is how to set a timeout when invoking a web service,:

Just go an open the composite properties, also there are other properties that are very useful.

The value in the property is in milliseconds.

AIA:Implementing wss-username-token (http basic authentication)

In this example I'll show you how to enable a web service security to your AIA artifacs.

To show you this I'll use an EBF component.

These are the high level steps:

1.- Create an user in weblogic console (this user is the one we can provide to any who wants to consume our service)

2.- Enable or make sure is ON the following web service policy AIA_EBF_WSServicePolicySet

3.- Restart the SOA instance.

4.- Test it.

Ok here are the steps in details.

1.- Create an user in weblogic console

  • Log in into the weblgic console and go to "Security Realms".
  • Select "myrealms"
  • Create a new user (in my case I created testusr)

2.- Enable or make sure is ON the following web service policy AIA_EBF_WSServicePolicySet

Log in into EM and go to "Weblogic Domain/your soa domain".
Right click in "your soa domain" and go though the menu to "Web Services/Policy Set"

Image goes here

Select the policy AIA_EBF_WSServicePolicySet and click the button "Edit"

<soapenv:Envelope xmlns:soapenv="" xmlns:tes="">
      <wsse:Security xmlns:wsse="">
            <wsse:Password Type="">qwerty12</wsse:Password>

Si se modifican los policy set hay que reiniciar el servidor para que se actualizen los cambios.

Tuesday, August 8, 2017

oracle soa tunning tips

Resolving Connection Timeouts

You can receive a connection timeout error under circumstances such as the following:
  • You run a SOA composite application with a large payload that takes more than 30 seconds to process.
  • You are invoking a stress test using a large payload from the Test Web Service page of Oracle Enterprise Manager Fusion Middleware Control Console.
  • You are passing a large number of message files (one million) into a composite with a file adapter service.
  • You are retrieving instance and fault count metrics in Oracle Enterprise Manager Fusion Middleware Control Console.
To avoid receiving timeout errors, increase the transaction timeout property as follows:
  1. Log into Oracle WebLogic Administration Console.
  2. Click JTA.
  3. Change the value of Timeout Seconds (the default is 30).
  4. Click Save.
  5. Restart Oracle WebLogic Server.

B.6 Increasing Database Connection Values

You can receive the following error message because of slow connections to the database.
Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 ( (Build 
090304)): oracle.toplink.exceptions.DatabaseException 
Internal Exception: java.sql.SQLException: Internal error: Cannot obtain 
XAConnection weblogic.common.resourcepool.ResourceDeadException: Pool 
SOADataSource has been disabled because of hanging connection tests, cannot 
allocate resources to applications.
If this occurs, perform the following steps:
  1. Open the DOMAIN_HOME\bin\setSOADomainEnv.cmd file.
  2. Uncomment the lines shown in bold.
    # 8331492: Value of weblogic.resourcepool.max_test_wait_secs is 10 
    # seconds. It can be increased by uncommenting line below if your database 
    # connections are slow. See SOA documentation for more details. 

Spring Security 4.0 problem authenticating - ALWAYS MOVING TO authentication-failure-url

This project is about authenticating using LDAP provider(ApacheDS), also I took the project from krams. I had to change the version of the spring security I used the following versions:

I did a lot of testing trying to make it work using context mapping example:

Using a RequestMapping path:

Also in the security spring

 at the web xml

Also what happened as well is that : at the form login in the security spring (check second image) file at the property login processing url instead of using the j_spring_security_check I used the login path, doing this I have solved the problem at the authentication part when entering the credentials it was always moving to the authentication failure url.

Keep in mind also we have to change the login page at the form tag and attribute attribute, I had to indicate as well using the login path.

Take a look in the previous image and it shows the login form using the input tags but named in the wrong way, leave it as it is it won't login as expected, the spring login form expects to receive the following names instead:

If we don't specify what is our custom login page, every time someone try to hit a page the does require login, it will redirect to the default login spring page instead of our custom. To fix this we need to specify the following in the security file:

When defining the logout form the key is to specify the log out tag in the spring security file, also implementing the url to do it is shown as follow:

XML to a File(CSV) in Eclipse

Download the plugin: Orangevolt Eclipse XSLT

Can be found here with explanation of how to install it:

I did the manual install since I got an error trying to update it from the reposutory, what I did was:
  • Download the zip
  • Uncompress and look for feature and plugin folders.
  • Put whatever is in feature and go to the eclipse installation and paste it in the same format
  • Do the same with plugin folder, put the jar files into the eclipse/plugin
Restart eclipse.
The examples below where extracted for stackoverflow:

This is another option to do the break line:

 <xsl:if test="not(position()=last())">
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" 
         xmlns:fo="" >
   <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
   <xsl:template match="/">
      <xsl:value-of select="concat('RowValue,Value', '&#xA;')"/>
      <xsl:for-each select="//RowOfValues[1]/RowValue">
         <xsl:variable name="pos" select="position()"/>
         <xsl:value-of select="normalize-space(.)"/>
         <xsl:call-template name="ScrapeColumns">
            <xsl:with-param name="pos" select="$pos"/>

   <xsl:template name="ScrapeColumns">
      <xsl:param name="pos"></xsl:param>
      <xsl:for-each select="//RowOfValues[position() > 1]//RowValue[position()=$pos]">
         <xsl:value-of select="concat(', ', normalize-space(.))"/>

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" 
                              xmlns:fo="" >
   <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
   <xsl:template match="/">
      <xsl:value-of select="concat('RowValue,Value', '&#xA;')"/>
      <xsl:for-each select="//RowOfValues[1]/RowValue">
         <xsl:variable name="pos" select="position()"/>
         <xsl:value-of select="concat(normalize-space(
                       concat(., ',', //RowOfValues[2]/RowValue[position()=$pos])),