Tuesday, November 27, 2012

XML validation against schema

We could use simple online tools to validate xml files against a single schema. But if we have more than one schema files, which are sub schemas of the base schema,  needed to validate a single xml file, we could use some other  tools which are availble freely.
I used libxml which works better. But for windows-64 bit platform, binary distribution is not available. We need to compile the source files. For linux, compilation would be easy.

Run xmllint from the "bin" folder

# xmllint --noout --schema <BASE_XSD_FILE>  <XML_FILE_TO_BE_VALIDATED>

If there are any errors it will be shown in the command prompt.

Everlasting songs..

Stress relieve music.



Monday, November 26, 2012

Configuring wso2esb to pass messages through proxy server

Organizations may expose the services over a proxy server for several purposes. In such a case, when user configures ESB, he has to provide proxy server configurations.
In axis2 configuration , at the transport sender configuration two properties has to be provided.
  • http.proxyHost : Proxy server's IP
  • http.proxyPort : Prosy server's port
eg :
 <transportSender name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSender">
        <parameter name="non-blocking" locked="false">true&lt;/parameter>
        <parameter name="http.proxyHost" locked="false">192.168.0.26  </parameter>
        <parameter name="http.proxyPort" locked="false">3128</parameter>
 </transportSender>
And a property (POST_TO_URI) has to be set in the synapse configuration to make ESB's out going URL a complete URL.

eg:
<inSequence>
    <property name="POST_TO_URI" value="true" scope="axis2"/>
    <send>
        <endpoint>
            <address uri="http://192.168.0.26:9000/services/SimpleStockQuoteService"/>
        </endpoint>
    </send>
</inSequence>
Depends on the proxy server's behaviour we may need to set some additional properties.
  • DISABLE_CHUNKING : If the proxy server doesn't support HTTP chunking. 
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
  • FORCE_HTTP_1.0 : If proxy server supports only HTTP/1.0 messages.
<property name="FORCE_HTTP_1.0" value="true" scope="axis2"/>
 These properties can be applied to WSO2API Manager as well, since WSO2ESB is used as the gateway for APIManager.

Saturday, November 24, 2012

Extracting CDATA section using XSLT

In a XML message, we pass some data which we might not want to be parsed by xml parsers.
Characters like "<>" are illegal in XML elements.  To save such characters we use CDATA section in our xml message.
For instance in the following xml message, we use CDATA block to pass <metadata> to other end without parsing "<,>" signs.
eg:


    <ser:getArtifactContentResponse    xmlns:ser="http://services.generic.governance.carbon.wso2.org">
    <ser:return>
         <![CDATA[
   <metadata xmlns="http://www.wso2.org/governance/metadata">
    <overview>       
        <name>scannapp&lt;/name>
        <developerId>developer702&lt;/developerId>
        <stateId>2&lt;/stateId>
        <serverURL>http://abc.com&lt;/serverURL>
        <id>cspapp1103&lt;/id>
        <description>scann doc&lt;/description>
        <hostingTypeId>1&lt;/hostingTypeId>       
    </overview>
</metadata>
  ]]>
  </ser:return>
</ser:getArtifactContentResponse>

 
To extract the CDATA section,( here it contains xml message) we could use simple xslt script.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" xmlns:ns="http://services.generic.governance.carbon.wso2.org">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" />
    <xsl:template match="/">
        <xsl:value-of select="//ns:getArtifactContentResponse/ns:return/text()" disable-output-escaping="yes"/>
    </xsl:template>
</xsl:stylesheet>
The output would be ;

   <metadata xmlns="http://www.wso2.org/governance/metadata">
    <overview>       
        <name>scannapp</name>
        <developerId>developer702</developerId>
        <stateId>2</stateId>
        <serverURL>http://abc.com</serverURL>
        <id>cspapp1103</id>
        <description>scann doc</description>
        <hostingTypeId>1</hostingTypeId>       
    </overview>
</metadata>

Friday, November 23, 2012

Everlasting songs..

Stress relieve music.







Thursday, November 22, 2012

Overcomming character encoding issue in windows for JAVA applications

I faced invalid UTF-8/character encoding issues multiple times recently when compiling/running aplictaions in java. We could enforce java VM to use the encoding pattern as UTF-8. To do that, set the following environment property.

variable name :   JAVA_TOOL_OPTIONS
variable value :   -Dfile.encoding=UTF8

Saturday, November 17, 2012

Professional liability?

It is more than three years now. The UN  Secretary-General Ban Ki-moon, accepts that UN failed to do its duty in Srilanka during the early 2009 last war.
Almost all medias including Al Jazeera,Channel 4,BBC,CNN reported continuously about  innocent civil people deaths.
Tamils around the world were stuck in front of TV to get to know what is happening in north. I was continuously checking for news updates in all tamil medias. Vanni was isolated, no contact with relations and friends. Still i remember , my friend continuously called and asked me to get the dead peoples' name to find out whether her family is safe or not.

UN did not take action, it rejected all requests from all corners. Now people died. Your acceptance/excuses never going to bring up their lives.
As a first duty or goal of UN, stand up and speak out for human rights and offer a voice to the voiceless. Tamils asked to give a voice. But you did not. As general public, we never want to know  about world politics. All what we need is, our safe and right to live.
Each profession has its own liability. None of the factors such as country,race,religion or money can influence on that.
Ban-ki-moon, still do you think you are done with the liability for the profession you hold?



Please stop learning from deaths!

Thursday, November 1, 2012

I am glad that I was surrounded ..

I am glad that I was surrounded by such enthusiastic students in the YIT geek challenge. But sadly i didn't know much to help them with their ideas which they had in  mind.
YIT team just finished successfully its first Geek challenge competition. It was just beyond amazing  in the  land which faced nearly thirty years civil war.

Competition was well organized by the team and it conducted  in a way, which we don't follow generally in IT project presentations.
It happened as 5 rounds and in each round participants' different IT skills were tested. I could say happily that the participants showed an extraordinary knowledge with their ideas though they are with less subject knowledge.

No one felt about losing the game but was willing to learn. Morning sessions went with guiding/mentoring the students and in the evenings, presentations were a debate among the judges,audience and teams.

Everyone asks me what are the good and bad points in this competition.To be honestly, i didn't expect such an interactive competition. With the less resources event was well organized. Hats off to the YIT onsite/ offsite organizers,mentors, judges and of course all teams who participated. You dreamed and it happened..

I saw  proud parents,teachers,lecturers and  entrepreneurs who with  hopes and big dream during the event.



participants are with mentors,judges and organizers


I had a 4 days wonderful time and it completely exceeded my expectations!