<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dimuthu's Blog &#187; Tutorial/Guide</title>
	<atom:link href="http://www.dimuthu.org/catagory/tutorialguide/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 07 Jul 2010 12:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
  <link>http://www.dimuthu.org</link>
  <url>http://www.dimuthu.org/favicon.ico</url>
  <title>Dimuthu's Blog</title>
</image>
		<item>
		<title>WSF/PHP Code First Approach: Returning an Array of String</title>
		<link>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 02:05:12 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml schema]]></category>
		<category><![CDATA[code first]]></category>
		<category><![CDATA[wsdl generation]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1060</guid>
		<description><![CDATA[Here is a problem that many people have asked me how to do it. &#8220;Returning an array of string&#8221; with the code first approach. The API or WSDL generation annotation guide, http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html contain all the things required in details. Here is an example of a service that return an array of string. &#60;?php /** splitMe [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a problem that many people have asked me how to do it. &#8220;Returning an array of string&#8221; with the code first approach. The API or WSDL generation annotation guide, <a href="http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html">http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html</a> contain all the things required in details. Here is an example of a service that return an array of string.</p>
<pre><span style="color: #000000; font-weight: bold;">&lt;?php</span>

<span style="color: #808080; font-style: italic;">/** splitMe function
 * @param string $string_to_split string to split
 * (maps to the xs:string XML schema type )
 * @return array of string $result split to array
 *(maps to the xs:double XML schema type )
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> splitMe<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$string_to_split</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"result"</span> =&gt; <a href="http://www.php.net/split"><span style="color: #000066;">split</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">":"</span>, <span style="color: #0000ff;">$string_to_split</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>

<span style="color: #0000ff;">$operations</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"splitMe"</span>=&gt;<span style="color: #ff0000;">"splitMe"</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$opParams</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"splitMe"</span>=&gt;<span style="color: #ff0000;">"MIXED"</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$svr</span> = <span style="color: #000000; font-weight: bold;">new</span> WSService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"operations"</span>=&gt;<span style="color: #0000ff;">$operations</span>,
                           <span style="color: #ff0000;">"bindingStyle"</span>=&gt;<span style="color: #ff0000;">"doclit"</span>,
                           <span style="color: #ff0000;">"opParams"</span>=&gt;<span style="color: #0000ff;">$opParams</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$svr</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
</pre>
<p>Note that the annotation corresponding to the return value.</p>
<pre> * @return array of spring $result split to array
</pre>
<p>This will generate an schema with an element of maxOccurs=&#8217;unbounded&#8217;. Note that you can get the wsdl from the &#8216;serviceurl?wsdl&#8217;.</p>
<pre><span style="font-weight: bold; color: black;">&lt;xsd:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"splitMeResponse"</span><span style="font-weight: bold; color: black;">&gt;</span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"result"</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">"unbounded"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xsd:string"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:element<span style="font-weight: bold; color: black;">&gt;</span>
</span></span></pre>
<p>Now just generate a client for this service using wsdl2php and try invoke it. You will get an array of string as the response.</p>
<pre>    <span style="color: #0000ff;">$input</span> = <span style="color: #000000; font-weight: bold;">new</span> splitMe<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">string_to_split</span> = <span style="color: #ff0000;">"a:b:c:d"</span>;

 
    <span style="color: #808080; font-style: italic;">// call the operation</span>
    <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$proxy</span>-&gt;<span style="color: #006600;">splitMe</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$input</span><span style="color: #66cc66;">)</span>;
    <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$response</span><span style="color: #66cc66;">)</span>;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing Business Rules in WSO2 Carbon Platform</title>
		<link>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 03:52:49 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[carbon]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[business rules]]></category>
		<category><![CDATA[esb]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1055</guid>
		<description><![CDATA[If you want to write rules in a Java program you have lot of choices. You can use a third party library like Drools or use the JAVA built-in JSR-94 reference implementation. In WSO2 Carbon, there is a component that abstract the behaviour of different rule engine and give you a unified API. Currently it [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to write rules in a Java program you have lot of choices. You can use a <a href="http://java-source.net/open-source/rule-engines">third party library</a> like Drools or use the JAVA built-in JSR-94 reference implementation. In <a href="http://wso2.org">WSO2</a> Carbon, there is a component that abstract the behaviour of different rule engine and give you a unified API. Currently it has plugged into Drools and JAVA built-in JSR-94 implementation.</p>
<p>The rule component in WSO2 Carbon platform mainly used by <a href="http://wso2.org/projects/esb/java">WSO2 ESB</a> product to mediate messages according to the given business rules. But the component is written to facilitate any requirement of using business rules in WSO2 Carbon platform. I had such a requirement in past few days and manage to use the rule component easily with the help of the component author, indika@wso2.com. So I thought it is worth sharing my experience in here.</p>
<p>Here You will be preparing the following stuff.</p>
<p>1. Rule configuration -</p>
<p>We can use this to provide the information about the rule implementation we are going to use, the rules (You can write rules inline or provide a reference to an external file) and the input and output adapter information.</p>
<pre><span style="font-weight: bold; color: black;">&lt;configuration</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">"http://www.wso2.org/products/rule/drools"</span><span style="font-weight: bold; color: black;">&gt;</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;executionSet</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">"simpleItemRuleXML"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;source</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"file:src/test/resources/rules/simple-rules.drl"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- &lt;source&gt;</span>
</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;x<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;"> rule InvokeABC</span>
<span style="color: #339933;"> // rules inbuilt to the rule conf</span>
<span style="color: #339933;"> end</span>

<span style="color: #339933;"> ]]&gt;</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/x<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/source<span style="font-weight: bold; color: black;">&gt;</span></span></span> --&gt;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;creation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"source"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"drl"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/creation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/executionSet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;session</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"stateless"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;input</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"facts"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"itemData"</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dataContext"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/input<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;output</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"results"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"itemData"</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dataContext"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/output<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;"><span style="font-weight: bold; color: black;">
</span></span></span></pre>
<p>2. The Rules  -</p>
<p>You can write rules inline in the above configuration or put it in a file and refer it from a key which can be refered from the ResourceHelper (described below).</p>
<pre><span style="color: #a1a100;">import java.util.Calendar;</span>

rule YearEndDiscount
when
$item : org.<span style="color: #006600;">test</span>.<span style="color: #006600;">pojo</span>.<span style="color: #006600;">SimpleItem</span><span style="color: #66cc66;">(</span>price &gt; <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">)</span>

then

<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a> calendar = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>calendar.<span style="color: #006600;">get</span><span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">MONTH</span><span style="color: #66cc66;">)</span> == <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">JANUARY</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

$item.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span>$item.<span style="color: #006600;">getPrice</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> * <span style="color: #cc66cc;">80</span>/<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

end
</pre>
<p>3. Data Context -</p>
<p>The context object that can be used to feed and retrieve data from and to rule engine. Here is the data context for my application.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleDataContext <span style="color: #66cc66;">{</span>

    <span style="color: #000000; font-weight: bold;">public</span> List&lt;NameValuePair&gt; getInput<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #808080; font-style: italic;">// in reality the data will be retrieve from a database or some datasource </span>
        List&lt;NameValuePair&gt; itemPairList = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;NameValuePair&gt;<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        SimpleItem item1 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item1.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item1"</span><span style="color: #66cc66;">)</span>;
        item1.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item1.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item1<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        SimpleItem item2 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item2.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item2"</span><span style="color: #66cc66;">)</span>;
        item2.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">120</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item2.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item2<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        SimpleItem item3 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item3.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item3"</span><span style="color: #66cc66;">)</span>;
        item3.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">130</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item3.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item3<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        <span style="color: #000000; font-weight: bold;">return</span> itemPairList;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setResult<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> result<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>result <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleItem<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"it is not a SimpleItem"</span><span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>

        SimpleItem item = <span style="color: #66cc66;">(</span>SimpleItem<span style="color: #66cc66;">)</span>result;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"Item: "</span> + item.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> + <span style="color: #ff0000;">", Price: "</span> + item.<span style="color: #006600;">getPrice</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

<span style="color: #66cc66;">}</span>
</pre>
<p>And the Item I&#8217;m going to manipulate using rule is a simple bean like this,</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleItem <span style="color: #66cc66;">{</span>
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name;
    <span style="color: #993333;">int</span> price;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getName<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> name;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setName<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">name</span> = name;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> getPrice<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> price;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setPrice<span style="color: #66cc66;">(</span><span style="color: #993333;">int</span> price<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">price</span> = price;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
</pre>
<p>4. Data Adapter</p>
<p>You have to adapt the input and output with the rule engine. Mostly here you only have to wrap the data context. The advantage of having the data adapter is, a data adapter always associated with a input/output type. So in the rule configuration I can provide the type for the input and output. If you see my rule configuration above, you see the input/output type is marked as &#8220;ItemData&#8221;.  Here is my custom data adapter that is associated with the &#8220;itemData&#8221; type.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleDataAdapter <span style="color: #000000; font-weight: bold;">implements</span>
        ResourceAdapter, InputAdaptable, OutputAdaptable <span style="color: #66cc66;">{</span>

    <span style="color: #808080; font-style: italic;">// the type associated with the adapter</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> TYPE = <span style="color: #ff0000;">"itemData"</span>;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getType<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> TYPE;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> adaptInput<span style="color: #66cc66;">(</span>ResourceDescription resourceDescription, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> tobeadapted<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>tobeadapted <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
        <span style="color: #66cc66;">}</span>

        SimpleDataContext dataContext = <span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>tobeadapted;
        <span style="color: #000000; font-weight: bold;">return</span> dataContext.<span style="color: #006600;">getInput</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> adaptOutput<span style="color: #66cc66;">(</span>ResourceDescription description,
                               <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> value,
                               <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> context,
                               ResourceHelper resourceHelper<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>context <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;
        <span style="color: #66cc66;">}</span>

        <span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>context<span style="color: #66cc66;">)</span>.<span style="color: #006600;">setResult</span><span style="color: #66cc66;">(</span>value<span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> canAdapt<span style="color: #66cc66;">(</span>ResourceDescription description, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> ouptput<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> key = description.<span style="color: #006600;">getKey</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">return</span> key != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; !<span style="color: #ff0000;">""</span>.<span style="color: #006600;">equals</span><span style="color: #66cc66;">(</span>key<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

<span style="color: #66cc66;">}</span>
</pre>
<p>5. Resource Helper</p>
<p>Resource Helper will map the keys refered from the configuration to JAVA objects. This is mostly used in mediation rule configurations which can extract the message data using a key or an xpath. In this example, we don&#8217;t have much keys refering from the configuration only the rule file and the data context.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleResourceHelper <span style="color: #000000; font-weight: bold;">extends</span> ResourceHelper <span style="color: #66cc66;">{</span>

    <span style="color: #000000; font-weight: bold;">public</span> ReturnValue findByKey<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> key, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> source, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> defaultValue<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>source <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>

        SimpleDataContext dataContext = <span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>source;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>key.<span style="color: #006600;">startsWith</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"file:"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> filename = key.<span style="color: #006600;">substring</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"file:"</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">{</span>

                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span></a> in = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span></a><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileInputStream</span></a><span style="color: #66cc66;">(</span>filename<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>in<span style="color: #66cc66;">)</span>;
            <span style="color: #66cc66;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
            <span style="color: #66cc66;">}</span>
        <span style="color: #66cc66;">}</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>key.<span style="color: #006600;">startsWith</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"dataContext"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>dataContext<span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">// there are few more methods to be implemented, which can just leave not implemented for this example</span>
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
</pre>
<p>That is all the accessories. Now you will be able to write the rule engine execution code.</p>
<pre><span style="color: #aaaadd; font-weight: bold;">File</span> ruleConfigFile = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">(</span>ruleConfigFilename<span style="color: #66cc66;">)</span>;
XMLStreamReader parser = XMLInputFactory.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>.<span style="color: #006600;">createXMLStreamReader</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileInputStream</span></a><span style="color: #66cc66;">(</span>ruleConfigFile<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">//create the builder</span>
StAXOMBuilder builder = <span style="color: #000000; font-weight: bold;">new</span> StAXOMBuilder<span style="color: #66cc66;">(</span>parser<span style="color: #66cc66;">)</span>;
<span style="color: #808080; font-style: italic;">//get the root element (in this case the envelope)</span>

OMElement ruleConfig =  builder.<span style="color: #006600;">getDocumentElement</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
EngineConfiguration configuration =
        <span style="color: #000000; font-weight: bold;">new</span> EngineConfigurationFactory<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>.<span style="color: #006600;">create</span><span style="color: #66cc66;">(</span>ruleConfig, <span style="color: #000000; font-weight: bold;">new</span> AXIOMXPathFactory<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

EngineController
        engineController = <span style="color: #000000; font-weight: bold;">new</span> EngineController<span style="color: #66cc66;">(</span>configuration, <span style="color: #000000; font-weight: bold;">new</span> SimpleResourceHelper<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">final</span> ResourceAdapterFactory factory = ResourceAdapterFactory.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

ResourceAdapter adapter = <span style="color: #000000; font-weight: bold;">new</span> SimpleDataAdapter<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> adapterType = adapter.<span style="color: #006600;">getType</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!factory.<span style="color: #006600;">containsResourceAdapter</span><span style="color: #66cc66;">(</span>adapterType<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

    factory.<span style="color: #006600;">addResourceAdapter</span><span style="color: #66cc66;">(</span>adapter<span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

SimpleDataContext simpleContext = <span style="color: #000000; font-weight: bold;">new</span> SimpleDataContext<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!engineController.<span style="color: #006600;">isInitialized</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    engineController.<span style="color: #006600;">init</span><span style="color: #66cc66;">(</span>simpleContext<span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>

<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>engineController.<span style="color: #006600;">isInitialized</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    engineController.<span style="color: #006600;">execute</span><span style="color: #66cc66;">(</span>simpleContext, simpleContext<span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting the size of BLOB in MySql</title>
		<link>http://www.dimuthu.org/blog/2010/01/06/getting-the-size-of-blob-in-mysql/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/06/getting-the-size-of-blob-in-mysql/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 02:53:32 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[OCTET_LENGTH]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1049</guid>
		<description><![CDATA[If you want to store binary in database, you can use BLOB as the data type of that column. In Mysql you can use TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB depending on your space requirement. Here is an example of database table using BLOB as a column type. CREATE TABLE BloBTest ( id INT NOT NULL AUTO_INCREMENT, [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to store binary in database, you can use <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html">BLOB</a> as the data type of that column. In Mysql you can use TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB depending on your space requirement. Here is an example of database table using BLOB as a column type.</p>
<pre><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> BloBTest <span style="color: #66cc66;">(</span>
    id INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,
    filename VARCHAR<span style="color: #66cc66;">(</span> <span style="color: #cc66cc;">32</span> <span style="color: #66cc66;">)</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
    content BLOB <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
    <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">(</span> id <span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">)</span></pre>
<p><strong>Storing Data</strong></p>
<p><strong>PHP:</strong></p>
<pre><span style="color: #0000ff;">$filename</span> = <span style="color: #ff0000;">"myimage.png"</span>;
<span style="color: #0000ff;">$filecontent</span> = <a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$filename</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$filecontent_escaped</span> = <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #000066;">mysql_real_escape_string</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$filecontent</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">"INSERT INTO BloBTest(filename, content) "</span> +
       <span style="color: #ff0000;">"VALUES('$filename','$filecontent_escaped')"</span>;
<a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$sql</span>, <span style="color: #0000ff;">$link</span><span style="color: #66cc66;">)</span>;</pre>
<p><strong> Java:</strong></p>
<pre><span style="color: #aaaadd; font-weight: bold;">String</span> filename = <span style="color: #ff0000;">"myimage.png"</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">InputStream</span></a> filecontent = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileInputStream</span></a><span style="color: #66cc66;">(</span>filename<span style="color: #66cc66;">)</span>;

<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> sql = <span style="color: #ff0000;">"INSERT INTO BloBTest(filename, content) VALUES(?, ?)"</span>;

<span style="color: #993333;">int</span> size = filecontent.<span style="color: #006600;">available</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3APreparedStatement+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">PreparedStatement</span></a> ps = conn.<span style="color: #006600;">prepareStatement</span><span style="color: #66cc66;">(</span>sql<span style="color: #66cc66;">)</span>;
ps.<span style="color: #006600;">setString</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span>, filename<span style="color: #66cc66;">)</span>;
ps.<span style="color: #006600;">setBinaryStream</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">2</span>, filecontent, size<span style="color: #66cc66;">)</span>;
ps.<span style="color: #006600;">executeUpdate</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</pre>
<p><strong>Retrieving Data</strong></p>
<p><strong>PHP</strong></p>
<pre><span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">"SELECT filename, content FROM BloBTest"</span>;
<span style="color: #0000ff;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$sql</span>, <span style="color: #0000ff;">$link</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #000066;">mysql_fetch_assoc</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$result</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

    <span style="color: #0000ff;">$filename</span> = <span style="color: #0000ff;">$row</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">"filename"</span><span style="color: #66cc66;">]</span>;
    <span style="color: #0000ff;">$content</span> = <span style="color: #0000ff;">$row</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">"content"</span><span style="color: #66cc66;">]</span>;
    <span style="color: #0000ff;">$new_filename</span> = <span style="color: #ff0000;">"new_"</span> . <span style="color: #0000ff;">$filename</span>;
    file_put_contents<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$new_filename</span>, <span style="color: #0000ff;">$content</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span></pre>
<p><strong>Java</strong>:</p>
<pre><span style="color: #aaaadd; font-weight: bold;">String</span> sql = <span style="color: #ff0000;">"SELECT filename, content FROM BloBTest"</span>;

PrepareStatement ps  = conn.<span style="color: #006600;">prepareStatement</span><span style="color: #66cc66;">(</span>resourceContentSQL<span style="color: #66cc66;">)</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AResultSet+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">ResultSet</span></a> result = ps.<span style="color: #006600;">executeQuery</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>result.<span style="color: #006600;">next</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span>
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> filename = result.<span style="color: #006600;">getString</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"filename"</span><span style="color: #66cc66;">)</span>;
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">InputStream</span></a> contentStream = result.<span style="color: #006600;">getBinaryStream</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"content"</span><span style="color: #66cc66;">)</span>;
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> newFilename = <span style="color: #ff0000;">"new_"</span> + filename;
    <span style="color: #808080; font-style: italic;">// storing the input stream in the file</span>

    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AOutputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">OutputStream</span></a> out=<span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileOutputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileOutputStream</span></a><span style="color: #66cc66;">(</span>newFilename<span style="color: #66cc66;">)</span>;
    <span style="color: #993333;">byte</span> buf<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">byte</span><span style="color: #66cc66;">[</span><span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">]</span>;
    <span style="color: #993333;">int</span> len;
    <span style="color: #b1b100;">while</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>len=contentStream.<span style="color: #006600;">read</span><span style="color: #66cc66;">(</span>buf<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>&gt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">)</span>

    out.<span style="color: #006600;">write</span><span style="color: #66cc66;">(</span>buf,<span style="color: #cc66cc;">0</span>,len<span style="color: #66cc66;">)</span>;
    out.<span style="color: #006600;">close</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span></pre>
<p><strong>Retrieving the Size of the Blob</strong></p>
<p>After you store your data as a blob, you can manipulate or query the data with some of the in-built <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html">String functions</a> in mysql. For an example if you want to query the size of the blob you just stored, you can use <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_octet-length">OCTET_LENGTH</a> function. Here is an example,  (this will give you the size in bytes.)</p>
<pre><span style="color: #993333; font-weight: bold;">SELECT</span> OCTET_LENGTH<span style="color: #66cc66;">(</span>content<span style="color: #66cc66;">)</span> <span style="color: #993333; font-weight: bold;">FROM</span> BloBTest <span style="color: #993333; font-weight: bold;">WHERE</span> filename=<span style="color: #ff0000;">'myimage.png'</span></pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 228px; width: 1px; height: 1px;">
<pre>.</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/06/getting-the-size-of-blob-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Register Today for WSO2 Governance as a Service</title>
		<link>http://www.dimuthu.org/blog/2010/01/05/register-today-for-wso2-governance-as-a-service/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/05/register-today-for-wso2-governance-as-a-service/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 12:32:38 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[GaaS]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[Governance Registry]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[gaas]]></category>
		<category><![CDATA[SaaS]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[wso2]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1035</guid>
		<description><![CDATA[WSO2 Governance as a Service is an online multi-tenant supported instance of WSO2 Governance Registry which is the solution for SOA Governance from the WSO2 SOA stack. You can start trying out WSO2 Governance as a Service by accessing the http://governance.cloud.wso2.com and creating an account for your organization (free for limited use). In order to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://governance.cloud.wso2.com/">WSO2 Governance as a Service</a> is an online multi-tenant supported instance of WSO2 Governance Registry which is the solution for SOA Governance from the WSO2 SOA stack. You can start trying out WSO2 Governance as a Service by accessing the <a href="http://governance.cloud.wso2.com">http://governance.cloud.wso2.com</a> and creating an account for your organization (free for limited use).</p>
<p>In order to identify your account, you have to provide the domain name of your organization. I will demonstrate how to create an account using the &#8220;ws.dimuthu.org&#8221; as my domain name.</p>
<p>1. First go to http://governance.cloud.wso2.com from a web browser and click the &#8216;Register&#8217; button. You will be asked to enter the domain name as the first step.</p>
<div id="attachment_1036" class="wp-caption aligncenter" style="width: 783px"><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/enter-domain.png"><img class="size-full wp-image-1036" title="Enter the domain" src="http://www.dimuthu.org/wp-content/uploads/2010/01/enter-domain.png" alt="Enter the domain" width="773" height="303" /></a><p class="wp-caption-text">Enter the domain</p></div>
<p>After that, you have the option of validating the ownership of the domain right at the registration process, or you can skip the validation and continue to the next step in which case your domain will be appended &#8216;-trial&#8217; suffix. You can validate the ownership of the domain later at any stage.</p>
<p>Here I want to validate the domain right now, so I click &#8216;Take me to the domain ownership confirmation page straight-away&#8217; and click the &#8216;Submit&#8217; button.</p>
<p>2. This will redirect you to the domain ownership validation page. You can validate the ownership of your domain in one of two ways.</p>
<p>Method i). Just create a text file named &#8216;wso2gaas.txt&#8217; in the web root of your domain and enter the given text. This is the most simplest method of two.</p>
<div id="attachment_1039" class="wp-caption aligncenter" style="width: 732px"><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/validate-domain-by-testfile.png"><img class="size-full wp-image-1039" title="validate-domain-by-textfile" src="http://www.dimuthu.org/wp-content/uploads/2010/01/validate-domain-by-testfile.png" alt="Validate domain name using Textfile" width="722" height="256" /></a><p class="wp-caption-text">Validate domain name using Textfile</p></div>
<p>Method ii). You can put a DNS entry according to the given instructions. This is a little tedious approch to validate the domain. In fact it may take a while to propagate the new DNS information, so you may have to wait hours without refreshing the page until you finally validate the domain ownership.</p>
<p><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/validate-domain-by-dns-entry.png"><img class="aligncenter size-full wp-image-1040" title="validate-domain-by-dns-entry" src="http://www.dimuthu.org/wp-content/uploads/2010/01/validate-domain-by-dns-entry.png" alt="" width="723" height="294" /></a></p>
<p>Click the continue button after the domain validation done. Then you will be redirected to a page requesting more information.</p>
<p>3. Tenant Registration Page</p>
<div id="attachment_1041" class="wp-caption aligncenter" style="width: 797px"><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/registration-page.png"><img class="size-full wp-image-1041" title="registration-page" src="http://www.dimuthu.org/wp-content/uploads/2010/01/registration-page.png" alt="Tenant Registration" width="787" height="478" /></a><p class="wp-caption-text">Tenant Registration</p></div>
<p>4) After this step, you will be notified to check for your email which will contain a mail with a link to proceed with the registration. There you will be able to select a theme for your organization and finalize creating your account. Login to the admin account for your tenant with the credential you provided a the time of the registration.</p>
<p>The domain ownership validation was introduced to WSO2 Governance as a Service account registration only now. So for organizations who have already have account will have a message similar to this when they are trying to login to their account.</p>
<div id="attachment_1046" class="wp-caption aligncenter" style="width: 470px"><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/login-warning-message.png"><img class="size-full wp-image-1046" title="login-warning-message" src="http://www.dimuthu.org/wp-content/uploads/2010/01/login-warning-message.png" alt="Info box at login" width="460" height="169" /></a><p class="wp-caption-text">Info box at login</p></div>
<p>So the account I have registered using the domain name &#8216;example.com&#8217; has been renamed to &#8216;example.com-trial&#8217;. As the instruction of the message says you can go to the account management page after the login and validate the domain ownership.</p>
<div id="attachment_1043" class="wp-caption aligncenter" style="width: 818px"><a href="http://www.dimuthu.org/wp-content/uploads/2010/01/account-mgt.png"><img class="size-full wp-image-1043" title="account-mgt" src="http://www.dimuthu.org/wp-content/uploads/2010/01/account-mgt.png" alt="Account Management Page" width="808" height="536" /></a><p class="wp-caption-text">Account Management Page</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/05/register-today-for-wso2-governance-as-a-service/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Code Generate Custom SOAP Faults For Axis2/C</title>
		<link>http://www.dimuthu.org/blog/2009/02/09/code-generate-custom-soap-faults-for-axis2c/</link>
		<comments>http://www.dimuthu.org/blog/2009/02/09/code-generate-custom-soap-faults-for-axis2c/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 06:04:41 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[2 minutes guide]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[codegen]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsdl2c]]></category>
		<category><![CDATA[xml schema]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[faults]]></category>
		<category><![CDATA[handling]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[throwing]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=916</guid>
		<description><![CDATA[Web services use SOAP faults to report fault cases back to clients. The faults can be generated from the SOAP framework in a case of invalid SOAP messages, invalid security tokens or they can be generated from the service business logic itself. The fault messages may contain simply a string indicating the error, or it [...]]]></description>
			<content:encoded><![CDATA[<p>Web services use SOAP faults to report fault cases back to clients. The faults can be generated from the SOAP framework in a case of invalid SOAP messages, invalid security tokens or they can be generated from the service business logic itself. The fault messages may contain simply a string indicating the error, or it may contain lot of details which could be useful to the clients find the problem. In fact the format of the SOAP fault is a standard. But services can send custom details within the details element in a SOAP fault.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;soapenv:Envelope</span> <span style="color: #000066;">xmlns:soapenv</span>=<span style="color: #ff0000;">"http://schemas.xmlsoap.org/soap/envelope/"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;soapenv:Body<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;soapenv:Fault<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faultcode<span style="font-weight: bold; color: black;">&gt;</span></span></span>soapenv:Sender<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faultcode<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;faultstring<span style="font-weight: bold; color: black;">&gt;</span></span></span>..<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/faultstring<span style="font-weight: bold; color: black;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;detail<span style="font-weight: bold; color: black;">&gt;</span></span></span> You Custom Message <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/detail<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/soapenv:Fault<span style="font-weight: bold; color: black;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/soapenv:Body<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/soapenv:Envelope<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>And you can define the schema of your custom fault message in a WSDL, so the clients can prepare to handle fault scenarios. In facts tools like <a href="http://ws.apache.org/axis2/">Apache Axis2</a> WSDL2C, WSDL2Java tool will help you to work with custom faults when they are defined in the WSDL.  Here is an example section of a WSDL with an operation which can throw two faults &#8220;MyFirstException&#8221;, &#8220;MySecondException&#8221;.</p>
<pre class="xml"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- fault schemas --&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;types<span style="font-weight: bold; color: black;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;schema</span> ..<span style="font-weight: bold; color: black;">&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MyFirstException"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xsd:string"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/element<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- fault element --&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MySecondException"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"number"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xsd:int"</span><span style="color: #ff0000;"></span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/element<span style="font-weight: bold; color: black;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/schema<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/types<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- the fault messages --&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;message</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MySecondExceptionFault"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"fault"</span> <span style="color: #000066;">element</span>=<span style="color: #ff0000;">"ns1:MySecondException"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/message<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;message</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MyFirstExceptionFault"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;part</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"fault"</span> <span style="color: #000066;">element</span>=<span style="color: #ff0000;">"ns1:MyFirstException"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/message<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- operation to throw fault --&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portType</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MyType"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"myOperation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;input</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">"tns:myOperationRequest"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;output</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">"tns:myOperationResponse"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;fault</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MySecondException"</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">"tns:MySecondExceptionFault"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;fault</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"MyFirstException"</span> <span style="color: #000066;">message</span>=<span style="color: #ff0000;">"tns:MyFirstExceptionFault"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
 <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/operation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portType<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>Note that the operation &#8220;myOperation&#8221; is throwing faults &#8220;MyFirstException&#8221;, &#8220;MySecondExcpetion&#8221;. If you generate the Java code for this operation, it would be simple as this,</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">public</span> MyOperationRequest
MyOperation<span style="color: #66cc66;">(</span>MyOperationRequest<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span>
          MyFirstExcpetion,
          MySecondExcpetion <span style="color: #66cc66;">{</span>
  <span style="color: #808080; font-style: italic;">// here is your business logic</span>
<span style="color: #66cc66;">}</span></pre>
<p>Anyway we are going to write codes in &#8216;C&#8217; language, which doesn&#8217;t have similar exception mechanism. Let see how we can do it, starting with writing the service and then writing a client.</p>
<p><strong>Writing Services With Custom SOAP Faults</strong></p>
<p>Once you generate the &#8216;C&#8217; codes for the WSDL using WSDL2C tool, you should first have a look at the skeleton header file.</p>
<pre class="c">    <span style="color: #808080; font-style: italic;">/**
     * the generated fault union for operation "myOperation|urn:myuri:1.0",
     * in a case you want to return a fault, put the appropriate adb object for
     * the union variable pointer comes as the last parameter of the method
     */</span>
    <span style="color: #993333;">typedef</span> <span style="color: #993333;">union</span>
    <span style="color: #66cc66;">{</span>
        adb_MyFirstException_t* MyFirstException;
        adb_MySecondException_t* MySecondException;

    <span style="color: #66cc66;">}</span> axis2_skel_MyService_myOperation_fault;

    <span style="color: #808080; font-style: italic;">/**
     * auto generated function declaration
     * for "myOperation|urn:myuri:1.0" operation.
     * @param env environment ( mandatory)
     * @param _myOperation of the adb_myOperation_t*
     *
     * @return adb_myOperationResponse_t*
     */</span>
    adb_myOperationResponse_t* axis2_skel_MyService_myOperation<span style="color: #66cc66;">(</span><span style="color: #993333;">const</span> axutil_env_t *env,
                                      adb_myOperation_t* _myOperation,
                                      axis2_skel_MyService_myOperation_fault *fault<span style="color: #66cc66;">)</span>;</pre>
<p>And at the very end of the header file, you will see an enumeration of constants corresponding to each fault is generated.</p>
<pre class="c">    <span style="color: #993333;">typedef</span> <span style="color: #000000; font-weight: bold;">enum</span>
    <span style="color: #66cc66;">{</span>
        AXIS2_SKEL_MYSERVICE_ERROR_NONE = AXIS2_SKEL_MYSERVICE_ERROR_CODES_START,

        AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION,
        AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION,

        AXIS2_SKEL_MYSERVICE_ERROR_LAST

    <span style="color: #66cc66;">}</span> axis2_skel_MyService_error_codes;</pre>
<p>That&#8217;s all you need to aware of. The plan is whenever you need to report the fault, you have to do three things inside the business logic.</p>
<ol>
<li>Create the adb object for the fault, in this case either &#8220;adb_MyFirstException_t&#8221; or &#8220;adb_MySecondException_t&#8221; and set it to the fault pointer variable.</li>
<li>Set the constant corresponding to the fault using &#8220;AXIS2_ERROR_SET&#8221; function</li>
<li>return NULL</li>
</ol>
<p>Here is an example how you do it inside the actual business logic code.</p>
<pre class="c">    adb_myOperationResponse_t* axis2_skel_MyService_myOperation<span style="color: #66cc66;">(</span><span style="color: #993333;">const</span> axutil_env_t *env,
                                      adb_myOperation_t* myOperation,
                                      axis2_skel_MyService_myOperation_fault *fault <span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #808080; font-style: italic;">/* the buisness logic */</span>

        ....

        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span><span style="color: #808080; font-style: italic;">/* checking some condition to throw the "MyFirstException" fault */</span><span style="color: #66cc66;">)</span>
        <span style="color: #66cc66;">{</span>
          <span style="color: #808080; font-style: italic;">/* 1. Creating the adb object and set it to the fault pointer variable */</span>
          adb_MyFirstException_t *exp = <span style="color: #000000; font-weight: bold;">NULL</span>;
          exp = adb_MyFirstException_create<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;
          adb_MyFirstException_set_text<span style="color: #66cc66;">(</span>exp, env, <span style="color: #ff0000;">"this is the exception 1"</span><span style="color: #66cc66;">)</span>; <span style="color: #808080; font-style: italic;">/* custom value */</span>

          fault-&gt;MyFirstException = exp;

          <span style="color: #808080; font-style: italic;">/* 2. Setting the error constant corrosponding to the fault */</span>
          AXIS2_ERROR_SET<span style="color: #66cc66;">(</span>env-&gt;error,
                      AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION,
                      AXIS2_FAILURE<span style="color: #66cc66;">)</span>;

          <span style="color: #808080; font-style: italic;">/* 3. Returning NULL */</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
        <span style="color: #66cc66;">}</span>

        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span><span style="color: #808080; font-style: italic;">/* checking some condition to throw the "MySecondException" fault */</span><span style="color: #66cc66;">)</span>
        <span style="color: #66cc66;">{</span>
          <span style="color: #808080; font-style: italic;">/* 1. Creating the adb object and set it to the fault pointer variable */</span>
          adb_MySecondException_t *exp = <span style="color: #000000; font-weight: bold;">NULL</span>;
          exp = adb_MySecondException_create<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;
          adb_MySecondException_set_number<span style="color: #66cc66;">(</span>exp, env, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span>;<span style="color: #808080; font-style: italic;">/* custom value */</span>

          fault-&gt;MySecondException = exp;

          <span style="color: #808080; font-style: italic;">/* 2. Setting the error constant corrosponding to the fault */</span>
          AXIS2_ERROR_SET<span style="color: #66cc66;">(</span>env-&gt;error,
                      AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION,
                      AXIS2_FAILURE<span style="color: #66cc66;">)</span>;
          <span style="color: #808080; font-style: italic;">/* 3. Returning NULL */</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
        <span style="color: #66cc66;">}</span>

        <span style="color: #808080; font-style: italic;">/* return the response in no fault scenario */</span>
        <span style="color: #b1b100;">return</span> response;
    <span style="color: #66cc66;">}</span></pre>
<p>That&#8217;s all you have to do, Axis2/C will make sure to build the fault and put your custom message inside the details element.</p>
<p><strong>Writing Clients  to Handle custom SOAP Faults</strong></p>
<p>After generating the code for clients using WSDL2C tool, this time you should look at the generated stub header file first. It is just similar to the skeleton header files may be except all the &#8220;skel&#8221; prefixes are renamed to &#8220;stub&#8221; and additional parameter &#8220;stub&#8221; for the operation.</p>
<pre class="c">    <span style="color: #808080; font-style: italic;">/**
     * the generated fault union for operation "myOperation|urn:myuri:1.0",
     * in a case the server return a fault, the corresponding adb object will be loaded for
     * the union variable pointer comes as the last parameter of the method
     */</span>
    <span style="color: #993333;">typedef</span> <span style="color: #993333;">union</span>
    <span style="color: #66cc66;">{</span>
        adb_MyFirstException_t* MyFirstException;
        adb_MySecondException_t* MySecondException;

    <span style="color: #66cc66;">}</span> axis2_stub_MyService_myOperation_fault;

    <span style="color: #808080; font-style: italic;">/**
     * auto generated function declaration
     * for "myOperation|urn:myuri:1.0" operation.
     * @param env environment ( mandatory)
     * @param _myOperation of the adb_myOperation_t*
     *
     * @return adb_myOperationResponse_t*
     */</span>
    adb_myOperationResponse_t* axis2_stub_MyService_myOperation<span style="color: #66cc66;">(</span>axis2_stub_t* stub, <span style="color: #993333;">const</span> axutil_env_t *env,
                                      adb_myOperation_t* _myOperation,
                                      axis2_stub_MyService_myOperation_fault *fault<span style="color: #66cc66;">)</span>;

    <span style="color: #993333;">typedef</span> <span style="color: #000000; font-weight: bold;">enum</span>
    <span style="color: #66cc66;">{</span>
        AXIS2_STUB_MYSERVICE_ERROR_NONE = AXIS2_STUB_MYSERVICE_ERROR_CODES_START,

        AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION,
        AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION,

        AXIS2_STUB_MYSERVICE_ERROR_LAST

    <span style="color: #66cc66;">}</span> axis2_stub_MyService_error_codes;</pre>
<p>Looking at this, you may have got the idea how to differentiate what fault is being thrown by the server and how to extract the parameters of the custom fault. Here is an example client code correctly handling exceptions.</p>
<pre class="c">    <span style="color: #808080; font-style: italic;">/* the structure to keep the fault */</span>
    axis2_stub_MyService_myOperation_fault fault;

    ..... <span style="color: #808080; font-style: italic;">/* the part preparing the request is ignored here */</span>

    <span style="color: #808080; font-style: italic;">/* invoking the "myOperation" operation */</span>
    response = axis2_stub_op_MyService_myOperation<span style="color: #66cc66;">(</span>stub, env, op, &amp;fault<span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* checking the response == NULL implies fault is sent  */</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span>response == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #808080; font-style: italic;">/* getting the error number to distinguish the fault */</span>
        error_code = env-&gt;error-&gt;error_number;

        <span style="color: #808080; font-style: italic;">/* compare error code with constants of each faults */</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span>error_code == AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <span style="color: #808080; font-style: italic;">/* extracting out the adb objects */</span>
            axis2_char_t *text = adb_MyFirstException_get_text<span style="color: #66cc66;">(</span>fault.<span style="color: #202020;">MyFirstException</span>, env<span style="color: #66cc66;">)</span>;

            <span style="color: #808080; font-style: italic;">/* do a printf of the message */</span>
            <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"My First Exception called: with param %s<span style="color: #000099; font-weight: bold;">\\</span>n"</span>, text<span style="color: #66cc66;">)</span>;

        <span style="color: #66cc66;">}</span>
        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span>error_code == AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #808080; font-style: italic;">/* extracting out the adb objects */</span>
            <span style="color: #993333;">int</span> number = adb_MySecondException_get_number<span style="color: #66cc66;">(</span>fault.<span style="color: #202020;">MySecondException</span>, env<span style="color: #66cc66;">)</span>;

            <span style="color: #808080; font-style: italic;">/* do a printf of the message */</span>
            <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"My Second Exception called: with param %d<span style="color: #000099; font-weight: bold;">\\</span>n"</span>, number<span style="color: #66cc66;">)</span>;

        <span style="color: #66cc66;">}</span>

    <span style="color: #66cc66;">}</span></pre>
<p>Note that this feature is available only in the very latest WSDL2C tool. Try to get latest build from <a href="http://ws.apache.org/axis2">Axis2/Java</a> to use this up to date tool.</p>
<p>You can download the WSDL and codes used in this example from here, <a href="https://issues.apache.org/jira/secure/attachment/12399724/case45.zip">https://issues.apache.org/jira/secure/attachment/12399724/case45.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2009/02/09/code-generate-custom-soap-faults-for-axis2c/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making Good SOA Great</title>
		<link>http://www.dimuthu.org/blog/2009/01/31/making-good-soa-great/</link>
		<comments>http://www.dimuthu.org/blog/2009/01/31/making-good-soa-great/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 13:36:10 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[carbon]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[enterprise]]></category>
		<category><![CDATA[OSGI]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=912</guid>
		<description><![CDATA[WSO2 is preparing for the first major release of their enterprise java product series after adapting the OSGI technology. You can already try out the betas from the wso2.org site. WSO2 Web Services Application Server (WSAS) WSO2 Enterprise Service Bus (ESB) WSO2 Registry WSO2 Business Process Server (BPS) With the power of OSGI you will [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wso2.com/">WSO2</a> is preparing for the first major release of their enterprise java product series after adapting the OSGI technology. You can already try out the betas from the <a href="http://wso2.org/projects/carbon">wso2.org</a> site.</p>
<ol>
<li><a href="http://wso2.org/projects/wsas/java">WSO2 Web Services Application Server (WSAS)<br />
</a></li>
<li><a href="http://wso2.org/projects/esb/java">WSO2 Enterprise Service Bus (ESB) </a></li>
<li><a href="http://wso2.org/projects/registry">WSO2 Registry </a></li>
<li><a href="http://wso2.org/projects/bps">WSO2 Business Process Server (BPS) </a></li>
</ol>
<p>With the power of OSGI you will be able to customize these products for your need just by mixing and matching the components within these products. If you like to learn more about this, just have a loot at the following ebook released by WSO2.</p>
<div id="attachment_913" class="wp-caption aligncenter" style="width: 310px"><a href="http://wso2.org/project/carbon/making_good_soa_great.pdf"><img class="size-medium wp-image-913" title="Making Good SOA Great" src="http://www.dimuthu.org/wp-content/uploads/2009/01/ebook-300x249.png" alt="Making Good SOA Great" width="300" height="249" /></a><p class="wp-caption-text">Making Good SOA Great</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2009/01/31/making-good-soa-great/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World To Web Services With C And C++</title>
		<link>http://www.dimuthu.org/blog/2009/01/22/hello-world-to-web-services-with-c-and-c/</link>
		<comments>http://www.dimuthu.org/blog/2009/01/22/hello-world-to-web-services-with-c-and-c/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 04:39:27 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[axiom]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/c++]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[wsf/cpp]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=903</guid>
		<description><![CDATA[Once you have a web service, you can write clients to invoke that service from any language, mostly with the help of a framework written in to that particular language. When it comes to C, the most popular choice is Apache Axis2/C framework. When you are using Axis2/C to write web service clients, you need [...]]]></description>
			<content:encoded><![CDATA[<p>Once you have a web service, you can write clients to invoke that service from any language, mostly with the help of a framework written in to that particular language. When it comes to C, the most popular choice is <a href="http://ws.apache.org/axis2/c/">Apache Axis2/C</a> framework. When you are using Axis2/C to write web service clients, you need to learn about AXIOM which is a easy to use high performing XML model and the service client API which can be used to actually invoke the service. Lets look at the code.</p>
<pre class="c"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;axiom.h&gt;</span>
<span style="color: #339933;">#include &lt;axis2_util.h&gt;</span>
<span style="color: #339933;">#include &lt;axiom_soap.h&gt;</span>
<span style="color: #339933;">#include &lt;axis2_client.h&gt;</span>

axiom_node_t *build_om_payload_for_helloworld_svc<span style="color: #66cc66;">(</span>
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>;

<span style="color: #993333;">int</span>
main<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    <span style="color: #993333;">const</span> axutil_env_t *env = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #993333;">const</span> axis2_char_t *address = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axis2_endpoint_ref_t *endpoint_ref = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axis2_options_t *options = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #993333;">const</span> axis2_char_t *client_home = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axis2_svc_client_t *svc_client = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_node_t *payload = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_node_t *ret_node = <span style="color: #000000; font-weight: bold;">NULL</span>;

    <span style="color: #808080; font-style: italic;">/* Set up the environment */</span>
    env = axutil_env_create_all<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"helloworld.log"</span>, AXIS2_LOG_LEVEL_TRACE<span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* Set end point reference of helloworld service */</span>
    address = <span style="color: #ff0000;">"http://localhost:9090/axis2/services/helloworld"</span>;

    <span style="color: #808080; font-style: italic;">/* Create EPR with given address */</span>
    endpoint_ref = axis2_endpoint_ref_create<span style="color: #66cc66;">(</span>env, address<span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* Setup options */</span>
    options = axis2_options_create<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;
    axis2_options_set_to<span style="color: #66cc66;">(</span>options, env, endpoint_ref<span style="color: #66cc66;">)</span>;
    axis2_options_set_action<span style="color: #66cc66;">(</span>options, env,
                             <span style="color: #ff0000;">"http://ws.apache.org/axis2/c/samples/helloworldString"</span><span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file. You need to set the AXIS2C_HOME variable to the axis2/c
     * installed dir.
     */</span>
    client_home = AXIS2_GETENV<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"AXIS2C_HOME"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!client_home || !strcmp<span style="color: #66cc66;">(</span>client_home, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
        client_home = <span style="color: #ff0000;">"../.."</span>;

    <span style="color: #808080; font-style: italic;">/* Create service client */</span>
    svc_client = axis2_svc_client_create<span style="color: #66cc66;">(</span>env, client_home<span style="color: #66cc66;">)</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!svc_client<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #808080; font-style: italic;">/* reporting the error */</span>
        <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a>
            <span style="color: #66cc66;">(</span><span style="color: #ff0000;">"Error creating service client, Please check AXIS2C_HOME again<span style="color: #000099; font-weight: bold;">\\</span>n"</span><span style="color: #66cc66;">)</span>;
        AXIS2_LOG_ERROR<span style="color: #66cc66;">(</span>env-&gt;log, AXIS2_LOG_SI,
                        <span style="color: #ff0000;">"Stub invoke FAILED: Error code:"</span> <span style="color: #ff0000;">" %d :: %s"</span>,
                        env-&gt;error-&gt;error_number,
                        AXIS2_ERROR_GET_MESSAGE<span style="color: #66cc66;">(</span>env-&gt;error<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
        <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">-1</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/* Set service client options */</span>
    axis2_svc_client_set_options<span style="color: #66cc66;">(</span>svc_client, env, options<span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* Build the SOAP request message payload using OM API. */</span>
    payload = build_om_payload_for_helloworld_svc<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;

    <span style="color: #808080; font-style: italic;">/* Send request */</span>
    ret_node = axis2_svc_client_send_receive<span style="color: #66cc66;">(</span>svc_client, env, payload<span style="color: #66cc66;">)</span>;

    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>ret_node<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #808080; font-style: italic;">/* extracting out the content from the response */</span>
        axis2_char_t *om_str = <span style="color: #000000; font-weight: bold;">NULL</span>;
        om_str = axiom_node_to_string<span style="color: #66cc66;">(</span>ret_node, env<span style="color: #66cc66;">)</span>;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>om_str<span style="color: #66cc66;">)</span>
            <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\\</span>nReceived OM : %s<span style="color: #000099; font-weight: bold;">\\</span>n"</span>, om_str<span style="color: #66cc66;">)</span>;
        <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\\</span>nhelloworld client invoke SUCCESSFUL!<span style="color: #000099; font-weight: bold;">\\</span>n"</span><span style="color: #66cc66;">)</span>;

        AXIS2_FREE<span style="color: #66cc66;">(</span>env-&gt;allocator, om_str<span style="color: #66cc66;">)</span>;
        ret_node = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #66cc66;">{</span>
        AXIS2_LOG_ERROR<span style="color: #66cc66;">(</span>env-&gt;log, AXIS2_LOG_SI,
                        <span style="color: #ff0000;">"Stub invoke FAILED: Error code:"</span> <span style="color: #ff0000;">" %d :: %s"</span>,
                        env-&gt;error-&gt;error_number,
                        AXIS2_ERROR_GET_MESSAGE<span style="color: #66cc66;">(</span>env-&gt;error<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
        <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"helloworld client invoke FAILED!<span style="color: #000099; font-weight: bold;">\\</span>n"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/* freeing the allocated memory */</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>svc_client<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        axis2_svc_client_free<span style="color: #66cc66;">(</span>svc_client, env<span style="color: #66cc66;">)</span>;
        svc_client = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        axutil_env_free<span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>axutil_env_t *<span style="color: #66cc66;">)</span> env<span style="color: #66cc66;">)</span>;
        env = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;
<span style="color: #66cc66;">}</span></pre>
<p>Here is the implementation of the &#8220;build_om_payload_for_helloworld_svc&#8221; function that build the request SOAP message using Axiom/C. Note that axiom_element and axiom_node has one to one association. We use node to to navigate the XML, where as axiom_element to store the data.</p>
<pre class="c"><span style="color: #808080; font-style: italic;">/* build SOAP request message content using OM
           &lt;ns1:greet xmlns:ns1="http://ws.apache.org/axis2/services/helloworld"&gt;
                &lt;text&gt;Hello World&lt;/text&gt;
           &lt;/ns1:greet&gt;
*/</span>
axiom_node_t *
build_om_payload_for_helloworld_svc<span style="color: #66cc66;">(</span>
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    axiom_node_t *helloworld_om_node = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_element_t *helloworld_om_ele = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_node_t *text_om_node = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_element_t *text_om_ele = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axiom_namespace_t *ns1 = <span style="color: #000000; font-weight: bold;">NULL</span>;
    axis2_char_t *om_str = <span style="color: #000000; font-weight: bold;">NULL</span>;

    ns1 =
       axiom_namespace_create<span style="color: #66cc66;">(</span>env, <span style="color: #ff0000;">"http://ws.apache.org/axis2/services/helloworld"</span>,
                               <span style="color: #ff0000;">"ns1"</span><span style="color: #66cc66;">)</span>;
    helloworld_om_ele =
        axiom_element_create<span style="color: #66cc66;">(</span>env, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #ff0000;">"greet"</span>, ns1, &amp;helloworld_om_node<span style="color: #66cc66;">)</span>;
    text_om_ele =
        axiom_element_create<span style="color: #66cc66;">(</span>env, helloworld_om_node, <span style="color: #ff0000;">"text"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, &amp;text_om_node<span style="color: #66cc66;">)</span>;
    axiom_element_set_text<span style="color: #66cc66;">(</span>text_om_ele, env, <span style="color: #ff0000;">"Hello World!"</span>, text_om_node<span style="color: #66cc66;">)</span>;
    om_str = axiom_node_to_string<span style="color: #66cc66;">(</span>helloworld_om_node, env<span style="color: #66cc66;">)</span>;

    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>om_str<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\\</span>nSending OM : %s<span style="color: #000099; font-weight: bold;">\\</span>n"</span>, om_str<span style="color: #66cc66;">)</span>;
        AXIS2_FREE<span style="color: #66cc66;">(</span>env-&gt;allocator, om_str<span style="color: #66cc66;">)</span>;
        om_str = <span style="color: #000000; font-weight: bold;">NULL</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #b1b100;">return</span> helloworld_om_node;
<span style="color: #66cc66;">}</span></pre>
<p>So lets see how the same thing is done with C++. For C++ we use <a href="http://wso2.org/projects/wsf/cpp">WSO2 WSF/C++</a></p>
<pre class="cpp"><span style="color: #339900;">#include &lt;stdio.h&gt;</span>
<span style="color: #339900;">#include &lt;WSSOAPClient.h&gt;</span>
<span style="color: #339900;">#include &lt;OMElement.h&gt;</span>
<span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;AxisFault.h&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std;
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> wso2wsf;

OMElement build_om_payload_for_helloworld_svc<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;

<span style="color: #0000ff;">int</span> main<span style="color: #000000;">(</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
    WSSOAPClient * sc = <span style="color: #0000dd;">new</span> WSSOAPClient<span style="color: #000000;">(</span><span style="color: #666666;">"http://localhost:9090/axis2/services/helloworld"</span><span style="color: #000000;">)</span>;
    sc-&gt;initializeClient<span style="color: #000000;">(</span><span style="color: #666666;">"helloworld_blocking.log"</span>, AXIS2_LOG_LEVEL_TRACE<span style="color: #000000;">)</span>;
    <span style="color: #000000;">{</span>
        <span style="color: #ff0000; font-style: italic;">/* generating the payload */</span>
        OMElement * payload = build_om_payload_for_helloworld_svc<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;

        OMElement * response;
        <span style="color: #0000ff;">try</span>
        <span style="color: #000000;">{</span>
            <span style="color: #ff0000; font-style: italic;">/* invoking the web service */</span>
            response = sc-&gt;request<span style="color: #000000;">(</span>payload, <span style="color: #666666;">"http://ws.apache.org/axis2/c/samples/helloworldString"</span><span style="color: #000000;">)</span>;

            <span style="color: #ff0000; font-style: italic;">/* printing the response */</span>
            <span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span>response<span style="color: #000000;">)</span>
            <span style="color: #000000;">{</span>
                <span style="color: #0000dd;">cout</span> &lt;&lt; endl &lt;&lt; <span style="color: #666666;">"Response: "</span> &lt;&lt; response &lt;&lt; endl;
            <span style="color: #000000;">}</span>
        <span style="color: #000000;">}</span>

        <span style="color: #ff0000; font-style: italic;">/* handling the fault */</span>
        <span style="color: #0000ff;">catch</span> <span style="color: #000000;">(</span>AxisFault &amp; e<span style="color: #000000;">)</span>
        <span style="color: #000000;">{</span>
            <span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span>sc-&gt;getLastSOAPFault<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>
            <span style="color: #000000;">{</span>
                <span style="color: #0000dd;">cout</span> &lt;&lt; endl &lt;&lt; <span style="color: #666666;">"Response: "</span> &lt;&lt; sc-&gt;getLastSOAPFault<span style="color: #000000;">(</span><span style="color: #000000;">)</span> &lt;&lt; endl;
            <span style="color: #000000;">}</span>
            <span style="color: #0000ff;">else</span>
            <span style="color: #000000;">{</span>
                <span style="color: #0000dd;">cout</span> &lt;&lt; endl &lt;&lt; <span style="color: #666666;">"Response: "</span> &lt;&lt; e &lt;&lt; endl;
            <span style="color: #000000;">}</span>
        <span style="color: #000000;">}</span>
        <span style="color: #0000dd;">delete</span> payload;
    <span style="color: #000000;">}</span>
    <span style="color: #0000dd;">delete</span> sc;
<span style="color: #000000;">}</span></pre>
<p>You can see lines of code is reduced a lot. And you can see it from the code to build the request XML as well.</p>
<pre class="cpp"><span style="color: #ff0000; font-style: italic;">/* building the request soap message
   &lt;ns1:greet xmlns:ns1="http://ws.apache.org/axis2/services/helloworld"&gt;
        &lt;text&gt;Hello World&lt;/text&gt;
   &lt;/ns1:greet&gt;
 */</span>
OMElement build_om_payload_for_helloworld_svc<span style="color: #000000;">(</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
    OMNamespace * ns = <span style="color: #0000dd;">new</span> OMNamespace<span style="color: #000000;">(</span><span style="color: #666666;">"http://ws.apache.org/axis2/services/helloworld"</span>, <span style="color: #666666;">"ns1"</span><span style="color: #000000;">)</span>;
    OMElement * payload = <span style="color: #0000dd;">new</span> OMElement<span style="color: #000000;">(</span><span style="color: #0000ff;">NULL</span>,<span style="color: #666666;">"greet"</span>, ns<span style="color: #000000;">)</span>;
    OMElement * child = <span style="color: #0000dd;">new</span> OMElement<span style="color: #000000;">(</span>payload,<span style="color: #666666;">"text"</span>, <span style="color: #0000ff;">NULL</span><span style="color: #000000;">)</span>;
    child-&gt;setText<span style="color: #000000;">(</span><span style="color: #666666;">"Hello World!"</span><span style="color: #000000;">)</span>;

    <span style="color: #0000ff;">return</span> payload;
<span style="color: #000000;">}</span></pre>
<p>WSF/C++ is build on top of Axis2/C. You can see the WSF/C++ API is designed very carefully to make it easy to use without breaking the flexibility provided in the C API. So C++ developers can straightaway use WSF/C++ to develop their web service consumers. Anyway Axis2/C API still has the power of embedding easily in to scripting languages  (Like it is done in WSF/PHP, WSF/Ruby) and probably deploy in legacy systems that doesn&#8217;t support C++ compiled binaries. So you have the options to select the most sutiable one for your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2009/01/22/hello-world-to-web-services-with-c-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article Introducing PHP Data Services</title>
		<link>http://www.dimuthu.org/blog/2009/01/05/article-introducing-php-data-services/</link>
		<comments>http://www.dimuthu.org/blog/2009/01/05/article-introducing-php-data-services/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 13:06:55 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WS-*]]></category>
		<category><![CDATA[ws-security]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=900</guid>
		<description><![CDATA[Now you can view the article I wrote titling &#8220;Introduction to PHP Data Services&#8220;. There I explain how you can design and implement Data Services in PHP using WSF/PHP Data Services Library. This article covers, Designing your Data Service API. Writing the Data Service. Deploying and Testing Data Service. Make the Data Service available in [...]]]></description>
			<content:encoded><![CDATA[<p>Now you can view the article I wrote titling &#8220;<a href="http://wso2.org/library/articles/introduction-php-data-services">Introduction to PHP Data Services</a>&#8220;. There I explain how you can design and implement Data Services in PHP using <a href="http://wso2.org/projects/wsf/php">WSF/PHP</a> Data Services Library.</p>
<p>This article covers,</p>
<ol>
<li>Designing your Data Service API.</li>
<li>Writing the Data Service.</li>
<li>Deploying and Testing Data Service.</li>
<li>Make the Data Service available in both SOAP and RESTful form.</li>
<li>Use of WS-* features in your Data Service.</li>
</ol>
<p>If you are thinking of adapting SOA in to your database backed PHP applications, this article will be a good starting point.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2009/01/05/article-introducing-php-data-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Web Services &#8211; Authentication Based on Client&#8217;s IP</title>
		<link>http://www.dimuthu.org/blog/2008/12/27/php-web-services-authentication-based-on-clients-ip/</link>
		<comments>http://www.dimuthu.org/blog/2008/12/27/php-web-services-authentication-based-on-clients-ip/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 10:34:10 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[$_SERVER]]></category>
		<category><![CDATA[authenticate]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[REMOTE_ADDR]]></category>
		<category><![CDATA[REMOTE_HOST]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=862</guid>
		<description><![CDATA[Explains with code samples how a PHP web service can be written to authenticate clients based on their IPs.]]></description>
			<content:encoded><![CDATA[<p>Same as web pages, web services also sometime require  client authentication. The most frequent way of authentication is the use of WS-Security Username token which authenticate clients based on the username and passwords. There can be situations where clients need to be authenticated based on its IP or its domain.</p>
<p>If you are writing web services from PHP (Using some PHP web service framework like <a href="http://wso2.org/projects/wsf/php">WSF/PHP</a>), You can use the PHP variables, <em>$_SERVER["REMOTE_ADDR"]</em> and <em>$_SERVER["REMOTE_HOST"]</em> to find the clients ip within the service logic code. If the client&#8217;s IP is static you can directly use the $_SERVER["REMOTE_ADDR"] and if it is dynamic you can use the $_SERVER["REMOTE_HOST"] which will be derived by reverse DNS look of the clients IP.</p>
<p>Here is one example of the use of these $_SERVER[] variables inside service logic.</p>
<pre class="php"> 
<span style="color: #000000; font-weight: bold;">function</span> members_only_func<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$in_message</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

<span style="color: #808080; font-style: italic;">    // getting the clients IP.</span>
    <span style="color: #0000ff;">$remote_addr</span> = <span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">"REMOTE_ADDR"</span><span style="color: #66cc66;">]</span>;

    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$remote_addr</span> == <span style="color: #ff0000;">"67.205.26.154"</span> ||
       <span style="color: #0000ff;">$remote_addr</span> == <span style="color: #ff0000;">"124.43.59.95"</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
       <span style="color: #808080; font-style: italic;">// generates the message for authenticated clients.</span>

       <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$valid_out_message</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">// otherwise throw an exception</span>
    throw <span style="color: #000000; font-weight: bold;">new</span> WSFault<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"Sender"</span>, <span style="color: #ff0000;">"Failed to Authenticate"</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

<span style="color: #0000ff;">$operations</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"membersOnlyOp"</span> =&gt; <span style="color: #ff0000;">"members_only_func"</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$service</span> = <span style="color: #000000; font-weight: bold;">new</span> WSService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"operations"</span> =&gt; <span style="color: #0000ff;">$operations</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$service</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/12/27/php-web-services-authentication-based-on-clients-ip/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Introduction to WSO2 Carbon &#8211; Componentized SOA Platform</title>
		<link>http://www.dimuthu.org/blog/2008/12/21/introduction-to-wso2-carbon-componentized-soa-platform/</link>
		<comments>http://www.dimuthu.org/blog/2008/12/21/introduction-to-wso2-carbon-componentized-soa-platform/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 13:48:13 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[carbon]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=837</guid>
		<description><![CDATA[&#8220;WSO2 carbon is a componentized, customizable SOA Platform, You can adapt the middleware to your enterprise architecture, rather than adapt your architecture to the middleware&#8221;. The Carbon Story]]></description>
			<content:encoded><![CDATA[<p>&#8220;WSO2 carbon is a componentized, customizable SOA Platform, You can adapt the middleware to your enterprise architecture, rather than adapt your architecture to the middleware&#8221;.</p>
<div id="__ss_855666" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="The Carbon Story" href="http://www.slideshare.net/wso2.org/the-carbon-story-presentation-855666?type=powerpoint">The Carbon Story</a><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=thecarbonstory-1229575799996446-2&amp;stripped_title=the-carbon-story-presentation-855666" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=thecarbonstory-1229575799996446-2&amp;stripped_title=the-carbon-story-presentation-855666" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/12/21/introduction-to-wso2-carbon-componentized-soa-platform/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
