Advertisements

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:

 
 1
 Article1
 This is article 1
 
 
 2
 Article2
 This is article 2
 
 
 3
 Article3
 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:
extension-element-prefixes="exsl"

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:
<xsl:value-of 
 select="substring(concat($string, '          '), 1, 10))"/>

if you need a left pad you can change the order of the concat parameters as following:
<xsl:value-of 
 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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://xmlns.oracle.com/Test/TestSecurityNotProducer">
      <soapenv:Header>
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken>
            <wsse:Username>weblogic</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">qwerty12</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <tes:process>
         <tes:input>Hello</tes:input>
      </tes:process>
   </soapenv:Body>
</soapenv:Envelope>


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 (11.1.1.1.0) (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. 
     EXTRA_JAVA_PROPERTIES="${EXTRA_JAVA_PROPERTIES}
    -Dweblogic.resourcepool.max_test_wait_secs=30" 
    export EXTRA_JAVA_PROPERTIES 

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:

http://www.ibm.com/developerworks/library/os-eclipse-orangevolt/

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: 

http://stackoverflow.com/questions/23263808/using-xsl-transformation-for-xml-to-csv-conversion

This is another option to do the break line:


 <xsl:if test="not(position()=last())">
   <xsl:text>&#xA;</xsl:text>
 </xsl:if>
and
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
         xmlns:fo="http://www.w3.org/1999/XSL/Format" >
   <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:call-template>
         <xsl:text>&#xA;</xsl:text>
      </xsl:for-each>
   </xsl:template>

   <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(.))"/>
      </xsl:for-each>   
   </xsl:template>
</xsl:stylesheet>
and

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                              xmlns:fo="http://www.w3.org/1999/XSL/Format" >
   <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])),
                    '&#xA;')"/>
      </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

How to escape text when pasting into Eclipse (including XML)

When you paste text into Eclipse it does just that - places where the cursor is in it's full un-altered original form. This is fine most of the time apart from when you might want to copy a chunk of XML (or a similar large body of text). What you end up with in this case is the text pasted in with red lines everywhere because the text hasn't been properly escaped for Java code.

To enable escaping of pasted text open the Preferences panel ('Window' menu -> 'Preferences...' option), then choose: 'Java' -> 'Editor' -> 'Typing' and tick the box which says "Escape text when pasting in a string literal":


Now whenever you post in text which is broken over multiple lines, Eclipse will insert the relevant quotes of Java to make Eclipse happy.

source: 
http://blog.andrewbeacock.com/2009/06/how-to-escape-text-when-pasting-into.html

How to mount a share folder in Linux using Vbox

In this section I'm going to show how to mount a share folder using windows (host) and Linx Mint (Guest).

Here are the steps.

1.- Install the guess tools.
go to Devices -> Install Guest Additions and double-click the CD that pops up on your desktop

2.- Make an empty directory you want to mount to

mkdir ~/NewShareFolder

3.- Now to perform the mount itself

sudo mount -t vboxsf ShareWin /ShareWin

4.- Crear el link a desktop using

ln -s /media/sf_share ~/Desktop/share

then add the group vboxsf to user eddocg

By doing this, you are granting permission to enter to /media/sf_share folder

sudo usermod -a -G vboxsf eddocg

Next time you logout or restart the VM you will be able to use the shared folder

Note: I'm assuming before doing all of this you setup the share folder in vbox itself. (add this in the future)

If it doesnt work we have to add the user to the group vboxsf

usermod -a -G vboxsf eddocg

then go to menu->Administration-> user and group
 
 
And that’s it. But if you want a permanent share, it’s even easier. When adding a permanent share, be sure to tick the “auto-mount” box – this means you won’t have to enter a mounting command every time you start up Linux again. Once you reboot, you’ll find the share mounted at /media/sf_sharename. Of course, that’s not terribly handy, so why not make a symlink to it (a shortcut)?
In this example I’m going to assume, again, that my share’s name is My_Dropbox, and I want to create a shortcut to it from the Desktop:
ln -s /media/sf_My_Dropbox ~/Desktop/Dropbox The nice thing about permanent shares is that they’re, well, permanent, so you’ll never have to go through this procedure again unless you’re mounting another share.
And that’s it, now the writing on your hard drive is easily accessible from inside your virtual machine.
 

Thursday, January 5, 2017

Guide for JMS and Active MQ

Here are some notes to start working with Active MQ.

Download from ‘Downloads’ section on ActiveMQ’s webpage, extract it to any directory and run the ‘activemq’ program from beneath the ‘{path-where-you-extracted-activemq}/bin’ directory:

execute: activemq start





Now the ActiveMQ server is up and running. ActiveMQ has a nice admin console, where you can see a lot of useful informations and change the settings:

The default username and password is admin/admin