<?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; services</title>
	<atom:link href="http://www.dimuthu.org/tag/services/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>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>RESTful PHP Web Services &#8211; Book Review</title>
		<link>http://www.dimuthu.org/blog/2009/01/01/restful-php-web-services-book-review/</link>
		<comments>http://www.dimuthu.org/blog/2009/01/01/restful-php-web-services-book-review/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 05:22:46 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[clients]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=865</guid>
		<description><![CDATA[PHP is one of the famous choice, when it comes to develop a web site. As the web evolve with the emerge of web service, REST (REpresentational State Transfer) concepts, the PHP language is also adapted to the new requirements specially with the availability of new SOA (Service Oriented Architecture), REST frameworks and libraries. Anyway [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is one of the famous choice, when it comes to develop a web site. As the web evolve with the emerge of web service, REST (REpresentational State Transfer) concepts, the PHP language is also adapted to the new requirements specially with the availability of new SOA (Service Oriented Architecture), REST frameworks and libraries. Anyway there were hardly any guides, references or samples that properly describe the methodologies of developing REST applications using PHP.</p>
<p>The book &#8220;<a href="http://www.packtpub.com/restful-php-web-services/book">RESTful PHP Web Services</a>&#8216; by <a href="http://samisa-abeysinghe.blogspot.com/">Samisa Abeysinghe</a> certainly fill this gap. It can be used as a step by step guideline for newbies to learn the concepts and write simple RESTful PHP applications and Mashups. And even experienced developers would find this a great reference to keep nearby while working with RESTful Web Services in PHP. And it has lot of code samples, utility functions that developers can use it in their applications.</p>
<p><a href="http://www.packtpub.com/restful-php-web-services/book"><img title="RESTful PHP Web Services - Samisa Abeysinghe" src="http://images.packtpub.com/images/full/1847195520.jpg" alt="RESTful PHP Web Services - Samisa Abeysinghe" width="200" /></a></p>
<p><strong>About the Author</strong></p>
<p><a href="http://samisa-abeysinghe.blogspot.com/">Samisa Abeysinghe</a> is a well recognized name in the web services world. He lead the development of <a href="http://ws.apache.org/axis2/c/">Apache Axis2/C</a> and <a href="http://wso2.org/projects/wsf/php">WSO2 WSF/PHP</a>, two famous open source web service frameworks for &#8216;C&#8217; and PHP. In addition to his deep knowledge in the subject, his experience in involving with the community and the enterprise for years and working as a lecturer in universities, should have influenced a lot in writing this book.</p>
<p><strong>The Arrangement and the Content</strong></p>
<p>The <a href="http://www.packtpub.com/article/restful-php-web-services-table-of-contents">arrangement of the book</a> is done really well to make sure the reader can go through it in the right sequence. All the content is bundled just within 200 pages. So you don&#8217;t need to allocate a lot of time to go through the whole book. It is organized into 7 chapters and two appendixes which are mostly independent from each other.</p>
<p>The first chapter is completely devoted to explain the concepts of RESTful web services. It basically explains what is RESTful web service and why it is needed. And it briefly mentions about the currently available REST Frameworks for PHP.</p>
<p>The second chapter introduce some PHP codes that do REST web service requests and handles the XML responses using both DOM and SimpleXML APIs. And in the third chapter it shows more code samples specially about consuming real world web services like BBC, Yahoo and an earthquakes information service. Theses codes are written as mashups mostly combining two services to produce more meaningful information.</p>
<p>The forth chapter is about  designing and writing web service providers. Its counterpart, writing web service consumers is described in the chapter five. There it demonstrate a library system that operate using RESTful webservices. You can map this example to any system that you may like to develop to run with RESTful web services.  The chapter five of the book is available as a free download, <a href="http://www.dimuthu.org/wp-content/uploads/2008/12/restful-php-webservices_sample-chapter.pdf">RESTful PHP Web Services &#8211; Chapter 5</a>.</p>
<p>The forth and fifth chapters are not using any framework to write the sample codes on consuming and providing web services. But in the sixth chapter it shows the use of <a href="http://framework.zend.com/">Zend framework</a> to do write them. There it rewrites the same example (The RESTful library system) in MVC (Model -View &#8211; Controller) approach using the functionalities of Zend framework. (In fact the View in the service is omitted).</p>
<p>The seventh chapter is about debugging web services. Debugging is a much needed step in any software development cycle. So if you are a newbie, you should read this chapter before start writing any of your own code. This introduces tools and methodologies to make your debugging easy and effective.</p>
<p>The book contains two appendixes. They are too really useful as the chapters of the book. In the first appendix it explains another REST web service framework, <a href="http://wso2.org/projects/wsf/php">WSO2 Web Services Framework for PHP (WSF/PHP)</a>. To demonstrate it uses, some selected functionalities of the example library system (that is mentioned in chapters 4, 5, 6) is re-implemented using WSF/PHP. And it shows you how you can convert this RESTful system to a SOAP system in a minute. The second appendix provides you a code of a class (RESTClient), that you can use in consuming web services very effectively.</p>
<p><strong>Recommended Readers<br />
</strong></p>
<p>This book assume you have some knowledge in PHP. But it doesn&#8217;t require you to know anything related to web services, REST or XML. As you read the first few chapters, you will have a good understanding on the concepts and the basic applications of REST and XML using PHP. And the later chapters will guide to get deeper knowledge in writing complex and real world applications.</p>
<p>If you are a professional developer, you can skip the introduction chapters and jump directly to where you need to refer. For an example, if you use this book as a reference in designing and developing RESTful web service providers, you can directly read the chapter4 &#8211; Resource Oriented Services, chapter6- Resource Oriented Clients and Services with Zend Framework and probably the chapter 7 &#8211; Debugging Web Services.</p>
<p>This book contains the same example system (the library system) written in three different approaches, first without using any framework support, second using the Zend Framework, third using WSF/PHP. Each of them has its own pros and cons. So if you want to determine the approach more suitable to your requirements, or thinking of migrating from one to another, this book will be an ideal resource for you.</p>
<p>As you may have already noticed, this book contains lot of code samples. All the concepts are followed by simple code samples that explain the concept. In appendix it gives you a complete code for RESTClient class that you can use to call any REST service. Apart from the code of the example library system written using different frameworks, it has lot of codes for calling public web service APIs. And the explanation of the code is also done really well.</p>
<p>So it is clear this book is more targetting readers who like to implement PHP RESTful Systems in practice. And it covers enough concepts that you needed to know in writing practicle applications. So this book can take you from the zero knowlege to a deeper knowlege of RESTful PHP Web Services.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2009/01/01/restful-php-web-services-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write RESTful Services in C</title>
		<link>http://www.dimuthu.org/blog/2008/10/18/write-restful-services-in-c/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/18/write-restful-services-in-c/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 17:40:14 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[services.xml]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=497</guid>
		<description><![CDATA[You can write REST as well as SOAP web services using Apache Axis2/C web services framework. There you can make existing Axis2/C web services RESTful just by providing the URL patterns and the HTTP methods to each operation in  the services.xml which act as a simple descriptor for an Axis2/C service. So if we rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>You can write REST as well as SOAP web services using <a href="http://www.dimuthu.org/">Apache Axis2/C</a> web services framework. There you can make existing Axis2/C web services RESTful just by providing the URL patterns and the HTTP methods to each operation in  the services.xml which act as a simple descriptor for an Axis2/C service.</p>
<p>So if we rewrite the <a href="http://labs.wso2.org/wsf/php/demo.php?name=RESTfulSchool&amp;demo=RESTFulSchool/demo_client.php&amp;src=RESTFulSchool">RESTful Demo</a> (Written in PHP) using Axis2/C, the services.xml would be something like following.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTfulSchool"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- mentioning the service library--&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"ServiceClass"</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">"xsd:false"</span><span style="font-weight: bold; color: black;">&gt;</span></span>RESTfulSchool<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- some description </span></span><span><span><span style="color: #009900;"><span style="font-style: italic; color: #808080;">-</span></span></span></span><span style="color: #009900;"><span style="font-style: italic; color: #808080;">-&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;description<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        The RESTful School demo
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/description<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- list of operations --&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;">"getSubjects"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTMethod"</span><span style="font-weight: bold; color: black;">&gt;</span></span>GET<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTLocation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>subjects<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"getSubjectInfoPerName"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTMethod"</span><span style="font-weight: bold; color: black;">&gt;</span></span>GET<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTLocation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>subjects/{name}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"getStudents"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTMethod"</span><span style="font-weight: bold; color: black;">&gt;</span></span>GET<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTLocation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>students<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"getStudentInfoPerName"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTMethod"</span><span style="font-weight: bold; color: black;">&gt;</span></span>GET<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTLocation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>students/{name}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;operation</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"getMarksPerSubjectPerStudent"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTMethod"</span><span style="font-weight: bold; color: black;">&gt;</span></span>GET<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"RESTLocation"</span><span style="font-weight: bold; color: black;">&gt;</span></span>students/{student}/marks/{subject}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;/service<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>We will check how to write the service logic for a operation like &#8220;getMarksPerSubjectPerStudent&#8221;.</p>
<pre class="c">axiom_node_t *
RESTfulSchool_getMarksPerSubjectPerStudent<span style="color: #66cc66;">(</span>
    <span style="color: #993333;">const</span> axutil_env_t * env,
    axiom_node_t * request_payload<span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    axiom_node_t *student_node = <span style="font-weight: bold; color: #000000;">NULL</span>;
    axiom_node_t *subject_node = <span style="font-weight: bold; color: #000000;">NULL</span>;

    <span style="font-style: italic; color: #808080;">/* Extracting out the child nodes from the request */</span>
    student_node = axiom_node_get_first_child<span style="color: #66cc66;">(</span>request_payload, env<span style="color: #66cc66;">)</span>;
    subject_node = axiom_node_get_next_sibling<span style="color: #66cc66;">(</span>student_node, env<span style="color: #66cc66;">)</span>;

    <span style="font-style: italic; color: #808080;">/* now we can write the logic to retrieve the marks
       for the given student and subject and build and
       return the response payload */</span>

    <span style="color: #b1b100;">return</span> response_payload;
<span style="color: #66cc66;">}</span></pre>
<p>As you can see the variables {student} and {subject} given in the services.xml can be easily accessed from your business logic, so we can build the response accordingly.</p>
<p>This way you can build a RESTful web services easily using C language.</p>
<p><a style="cursor: pointer; color: green;"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/18/write-restful-services-in-c/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Understanding Apache Axis2/C Services</title>
		<link>http://www.dimuthu.org/blog/2008/10/02/understanding-apache-axis2c-services/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/02/understanding-apache-axis2c-services/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 10:20:36 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[axis2.xml]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[Skeleton]]></category>
		<category><![CDATA[svc_skeleton]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=425</guid>
		<description><![CDATA[If you have ever written an Apache Axis2/C service, there is a 99.9% chance that you have used the codegen tool to generate the code for the service. If so you only need to write your business logic inside functions generated by the the tool. But there may be situations that you can&#8217;t use the [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever written an <a href="http://ws.apache.org/axis2/c">Apache Axis2/C</a> service, there is a 99.9% chance that you have used the codegen tool to generate the code for the service. If so you only need to write your business logic inside functions generated by the the tool.</p>
<p>But there may be situations that you can&#8217;t use the codegen tool to get your work done. May be you don&#8217;t have a WSDL. Or codegen tool fails generating code for you WSDL (very few chance <img src='http://www.dimuthu.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>In these situations you have to go to writing the complete service manually, I.e. You will write the code for the business logic + Axis2 Skeleton (code to plug the service logic to axis2/c).</p>
<p>Axis2/C service consists on:</p>
<ul>
<li>service.xml &#8211; Simple way to describe the service and operation. (Far simpler than a wsdl)</li>
<li>Skeleton &#8211; c pseudo class inherited from axis2_svc_skeleton</li>
<li>Service logic &#8211; You service logic per service operation</li>
</ul>
<p><strong>services.xml</strong></p>
<p>This contain the name and some description of the service, the name of the .dll (in windows) or .so (in linux) to load the service and list of operations with their parameters.</p>
<p>E.g.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"echo"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
  <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- dll or so name of the service --&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"ServiceClass"</span> <span style="color: #000066;">locked</span>=<span style="color: #ff0000;">"xsd:false"</span><span style="font-weight: bold; color: black;">&gt;</span></span>echo<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;description<span style="font-weight: bold; color: black;">&gt;</span></span></span>This is a testing service, to test whether the system is working or not<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/description<span style="font-weight: bold; color: black;">&gt;</span></span></span> 

  <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- list of operations --&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;">"echoString"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- addressing information for the operation--&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"wsamapping"</span><span style="font-weight: bold; color: black;">&gt;</span></span>http://ws.dimuthu.org/axis2/echoString<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/parameter<span style="font-weight: bold; color: black;">&gt;</span></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;/service<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>In addition to shown ones, there are a bunch of parameters available to customize your service. Visit <a href="http://ws.apache.org/axis2/c/docs/axis2c_manual.html#appB">Axis2/C manual</a> for more.<br />
<strong>Skeleton</strong><br />
This is the code that form the dll for your service. At least you should implement the following set of functions there.</p>
<ul>
<li>Required function to create any axis2/c DLL
<ul>
<li>axis2_get_instance &#8211; Call at the creation of the DLL</li>
<li>axis2_remove_instance &#8211; Call at the removal of the DLL</li>
</ul>
</li>
<li>Functions to be implement the axis2_svc_skeleton interface (sorry I&#8217;m using the java jargons)
<ul>
<li>init- Initialize the service (execute per start of the server)</li>
<li>invoke &#8211; invocation of the service (execute per each client request)</li>
<li>on_fault &#8211; invocation of the fault (execute if invoke returns NULL with error set)</li>
<li>free &#8211; Freeing the service (execute per stop of the server)</li>
</ul>
</li>
<li> In addition to these mandatory functions I will be using axis2_echo_create to create the service skeleton for the echo service.</li>
</ul>
<p>I will start with showing the structure of the service skeleton functions first.</p>
<pre class="c"><span style="font-style: italic; color: #808080;">/**
 * echo free method
 */</span>
<span style="color: #993333;">int</span> AXIS2_CALL echo_free<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * svc_skeleton,
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">/**
 * echo invoke method
 */</span>
axiom_node_t *AXIS2_CALL echo_invoke<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * svc_skeleton,
    <span style="color: #993333;">const</span> axutil_env_t * env,
    axiom_node_t * node,
    axis2_msg_ctx_t * msg_ctx<span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">/**
 * echo init method
 */</span>
<span style="color: #993333;">int</span> AXIS2_CALL echo_init<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * svc_skeleton,
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">/**
 * echo on_fault method
 */</span>
axiom_node_t *AXIS2_CALL echo_on_fault<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * svc_skeli,
    <span style="color: #993333;">const</span> axutil_env_t * env,
    axiom_node_t * node<span style="color: #66cc66;">)</span>;</pre>
<p>Note that you have the freedom to give any name to each of these function. In fact you should give a name with your service name as the prefix to avoid name conflicts. Then you can specify service skeleton to take these functions to represent to init, invoke, on_fault, free methods using the following code.</p>
<pre class="c"><span style="font-style: italic; color: #808080;">/**
 * you should specify your functions set exactly in the order
 * init, invoke, on_fault, free
 */</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">const</span> axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = <span style="color: #66cc66;">{</span>
    echo_init,
    echo_invoke,
    echo_on_fault,
    echo_free
<span style="color: #66cc66;">}</span>;

<span style="font-style: italic; color: #808080;">/**
 * Create function
 */</span>
axis2_svc_skeleton_t *
axis2_echo_create<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>
    axis2_svc_skeleton_t *svc_skeleton = <span style="font-weight: bold; color: #000000;">NULL</span>;
    <span style="font-style: italic; color: #808080;">/* Allocate memory for the structs */</span>
    svc_skeleton = AXIS2_MALLOC<span style="color: #66cc66;">(</span>env-&gt;allocator, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">(</span>axis2_svc_skeleton_t<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

    <span style="font-style: italic; color: #808080;">/* you give the function pointers array to the ops of the skeleton */</span>
    svc_skeleton-&gt;ops = &amp;echo_svc_skeleton_ops_var;

    svc_skeleton-&gt;func_array = <span style="font-weight: bold; color: #000000;">NULL</span>;

    <span style="color: #b1b100;">return</span> svc_skeleton;
<span style="color: #66cc66;">}</span></pre>
<p>So you create the service skeleton for your echo service inside the axis2_echo_create function. In fact you need to call this function from the DLL creation function (i.e. &#8216;axis2_get_instance&#8217; funciton). And in the &#8216;axis2_remove_instance&#8217; function you call the macro AXIS2_SVC_SKELETON_FREE which in fact call the echo_free function to free the resource at the removal of DLL. Here are the implementation for the DLL creation and removal functions in this particular service.</p>
<pre class="c"><span style="font-style: italic; color: #808080;">/**
 * Calls at the creation of the dll.
 */</span>
AXIS2_EXPORT <span style="color: #993333;">int</span>
axis2_get_instance<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t ** inst,
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    *inst = axis2_echo_create<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>*inst<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #b1b100;">return</span> AXIS2_FAILURE;
    <span style="color: #66cc66;">}</span>

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

<span style="font-style: italic; color: #808080;">/**
 * Calls at the removal of the dll.
 */</span>
AXIS2_EXPORT <span style="color: #993333;">int</span>
axis2_remove_instance<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * inst,
    <span style="color: #993333;">const</span> axutil_env_t * env<span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    axis2_status_t status = AXIS2_FAILURE;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>inst<span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        status = AXIS2_SVC_SKELETON_FREE<span style="color: #66cc66;">(</span>inst, env<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #b1b100;">return</span> status;
<span style="color: #66cc66;">}</span></pre>
<p>Up to this, it was all about preparing the service skeleton, So where you put your business logic?.</p>
<p><strong>Service logic</strong></p>
<p>Just create a function with the following format.</p>
<pre class="c">axiom_node_t *axis2_echo_echo<span style="color: #66cc66;">(</span>
    <span style="color: #993333;">const</span> axutil_env_t * env,
    axiom_node_t * input_node<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

    <span style="font-style: italic; color: #808080;">/* Write your business logic Right Here */</span>
<span style="color: #66cc66;">}</span></pre>
<p>Here you extract out the input parameters from the the input_node and build the return node based on your output parameters. (Note that even though this is an echo example you can&#8217;t return the same input node as the output node, instead you have to replicate the input node and return it to avoid the double freeing)<br />
Since this particular example you only have one operation you can call your business logic right inside of your echo_invoke function. But it doens&#8217;t work for cases where multiple operations present. Here is the right way to do it.</p>
<pre class="c"><span style="font-style: italic; color: #808080;">/*
 * This method invokes the right service logic
 */</span>
axiom_node_t *AXIS2_CALL
echo_invoke<span style="color: #66cc66;">(</span>
    axis2_svc_skeleton_t * svc_skeleton,
    <span style="color: #993333;">const</span> axutil_env_t * env,
    axiom_node_t * node,
    axis2_msg_ctx_t * msg_ctx<span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
	axis2_op_ctx_t *operation_ctx = <span style="font-weight: bold; color: #000000;">NULL</span>;
	axis2_op_t *operation = <span style="font-weight: bold; color: #000000;">NULL</span>;
	axutil_qname_t *op_qname = <span style="font-weight: bold; color: #000000;">NULL</span>;
	axis2_char_t *op_name = <span style="font-weight: bold; color: #000000;">NULL</span>;

	<span style="font-style: italic; color: #808080;">/* logic to get the op name from message context */</span>
	operation_ctx = axis2_msg_ctx_get_op_ctx<span style="color: #66cc66;">(</span>msg_ctx, env<span style="color: #66cc66;">)</span>;
	operation = axis2_op_ctx_get_op<span style="color: #66cc66;">(</span>operation_ctx, env<span style="color: #66cc66;">)</span>;
	op_qname = <span style="color: #66cc66;">(</span>axutil_qname_t *<span style="color: #66cc66;">)</span>axis2_op_get_qname<span style="color: #66cc66;">(</span>operation, env<span style="color: #66cc66;">)</span>;
	op_name = axutil_qname_get_localpart<span style="color: #66cc66;">(</span>op_qname, env<span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">/* compare it with our operation name, this is useful when
	   there are multiple operations exist */</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>op_name<span style="color: #66cc66;">)</span>
	<span style="color: #66cc66;">{</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!axutil_strcmp<span style="color: #66cc66;">(</span>op_name, <span style="color: #ff0000;">"echoString"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
		<span style="color: #66cc66;">{</span>
			<span style="color: #b1b100;">return</span> axis2_echo_echo<span style="color: #66cc66;">(</span>env, node<span style="color: #66cc66;">)</span>;
		<span style="color: #66cc66;">}</span>
	<span style="color: #66cc66;">}</span>

	<span style="font-style: italic; color: #808080;">/* set error in the failure path */</span>
	AXIS2_ERROR_SET<span style="color: #66cc66;">(</span>env-&gt;error, AXIS2_ERROR_OP_NAME_MISSING, AXIS2_FAILURE<span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">/* log the error */</span>
	AXIS2_LOG_ERROR<span style="color: #66cc66;">(</span> env-&gt;log, AXIS2_LOG_SI, <span style="color: #ff0000;">"op name %s is not known"</span>, op_name<span style="color: #66cc66;">)</span>;

	<span style="color: #b1b100;">return</span> <span style="font-weight: bold; color: #000000;">NULL</span>;
<span style="color: #66cc66;">}</span></pre>
<p>So that&#8217;s the part you write the code. Compile the code linking necessary libraries in the lib directory of your axis2/c pack and don&#8217;t forget to include the necessary axis2/c headers.</p>
<ul>
<li> Necessary libraries for linux (Note: Some libraries are not directly called from your code, but it s better link all as some systems may complain about missing symbols in run time)
<ul>
<li> libaxutil.so</li>
<li> libaxis2_axiom.so</li>
<li> libaxis2_engine.so</li>
<li> libaxis2_parser.so</li>
<li> libpthread.so</li>
<li> libaxis2_http_sender.so</li>
<li> libaxis2_http_receiver.so</li>
<li> libguththila.so</li>
</ul>
</li>
<li> Necessary libraries for Windows
<ul>
<li> axiom.lib</li>
<li> axis2_engine.lib</li>
<li> axis2_parser.lib</li>
<li> axutil.lib</li>
</ul>
</li>
<li> Necessary header files (for both windows and linux)
<ul>
<li> axis2_svc_skeleton.h &#8211; To create instance of svc_skeleton</li>
<li> axis2_msg_ctx.h &#8211; Required in retrieving the dispatched operation name</li>
</ul>
</li>
</ul>
<p>If you follow this post up to now, this is the time you deploy the service with Axis2/C. Create a directory called &#8216;echo&#8217; inside the services directory of axis2 repository (the root directory of you put axis2/c binary) and copy the services.xml and the dll  in to that. (The DLL should be in the name echo.dll or libecho.so, if you change the dll name you should update the services.xml &#8220;ServiceClass&#8221; parameter).</p>
<p>Start the axis2 simple server (which is located in the &lt;axis2_c_repo&gt;/bin) and you are done. Your service will be deployed in &#8220;http://localhost/axis2/services/echo&#8221;. Use this endpoint to access your brand new service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/02/understanding-apache-axis2c-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
