<?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; RESTful</title>
	<atom:link href="http://www.dimuthu.org/tag/restful/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>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>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>RESTful URL Mapping in WSF/PHP</title>
		<link>http://www.dimuthu.org/blog/2008/11/16/restful-url-mapping-in-wsfphp/</link>
		<comments>http://www.dimuthu.org/blog/2008/11/16/restful-url-mapping-in-wsfphp/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 17:21:49 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[SQL]]></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[data services]]></category>
		<category><![CDATA[DataService]]></category>
		<category><![CDATA[RESTfulSchool]]></category>
		<category><![CDATA[URL Mapping]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=621</guid>
		<description><![CDATA[In a RESTful design, choose of URLs for resources are really important. The URL uniquely represents a resource. Service consumers can change some parts in the URL to access different other resources. So it is clear that the URL consists of some constant parts which describe the resource group or catalog in general and some [...]]]></description>
			<content:encoded><![CDATA[<p>In a RESTful design, choose of URLs for resources are really important. The URL uniquely represents a resource. Service consumers can change some parts in the URL to access different other resources. So it is clear that the URL consists of some constant parts which describe the resource group or catalog in general and some variable parts which have different and unique values for different resources.</p>
<p>As an example look at the following URL patterns</p>
<ul>
<li>students/{name} &#8211; The constant &#8216;students&#8217; represent the students group in general and the variable &#8216;name&#8217; is used to identify each student individually.</li>
<li>students/{name}/marks/{subject} &#8211; The constants &#8216;students&#8217; and &#8216;marks&#8217; shows that this resource is a marks of some students, The two variables &#8216;name&#8217; and &#8216;subjects&#8217; addresses which student and marks of which subject is presented in the URL.</li>
</ul>
<p>You can have a look at some of the uses of such mappings from <a href="http://labs.wso2.org/wsf/php/resource_view.php?url=RESTfulSchool">RESTful School demo</a>.</p>
<p><a href="http://wso2.org/projects/wsf/php">WSF/PHP</a> allows you to create RESTful Web Services and further more RESTful Data Services in PHP.</p>
<p>In a RESTful Data Service you expose a database query as a web service. There you can write a prepared statement and feed arguments for the statement through the variable parameters of the URL. For an example take the <a href="http://labs.wso2.org/wsf/php/source_page_old.php?src=solutions%2FRESTFulSchool%2Fschool_service.php">RESTfulSchool Demo Code</a>.</p>
<p>To retrieve a particular student, we can use the following prepared statement and the URL pattern ( This URL Pattern+  HTTP &#8216;GET&#8217; method is matched to execute this query. )</p>
<pre class="php"><span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">"SELECT * FROM Students where StudentName = ?"</span>

<span style="color: #0000ff;">$get_students_with_name_url</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"HTTPMethod"</span> =&gt; <span style="color: #ff0000;">"GET"</span>,
                 <span style="color: #ff0000;">"RESTLocation"</span> =&gt; <span style="color: #ff0000;">"students/{name}"</span><span style="color: #66cc66;">)</span>;</pre>
<p>So you can execute this prepared statement with the subject name &#8216;John&#8217; using the following URL.</p>
<pre><a href="http://labs.wso2.org/wsf/php/solutions/RESTFulSchool/school_service.php/students/john">http://labs.wso2.org/wsf/php/solutions/RESTFulSchool/school_service.php/students/john</a></pre>
<p>If your service is not exposing the database directly, then you have to choose the general web service API rather than the data service specific API. In there you will be able to write your business logic for publishing student information in a PHP function and expose it as a web service.</p>
<p>In such a cas,e your function is taking an argument which of type <a href="http://wso2.org/project/wsf/php/2.0.0/docs/api_content.html#message">WSMessage</a>. This structure hold an XML that contains values for all the variable parameters as in the users request URL. For an example for above REST Mapping, we can expect the following XML.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;getSubject<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>Chemistry<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/getSubject<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>And your function to expose as a service, would be look like this,</p>
<pre class="php"><span style="font-weight: bold; color: #000000;">function</span> getSubject<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$input</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    <span style="font-style: italic; color: #808080;">/* retrieve the subject name from the
       $input xml using simple xml */</span>

    <span style="color: #0000ff;">$input_xml</span> = <span style="font-weight: bold; color: #000000;">new</span> SimpleXMLElement<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">str</span><span style="color: #66cc66;">)</span>;

    <span style="color: #0000ff;">$subject_name</span> = <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">name</span>;

    <span style="font-style: italic; color: #808080;">/* write the logic to retrieve subject information
      for the $subject_name */</span>

    ....
<span style="color: #66cc66;">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/11/16/restful-url-mapping-in-wsfphp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book on RESTful PHP Web Services</title>
		<link>http://www.dimuthu.org/blog/2008/10/21/book-on-restful-php-web-services/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/21/book-on-restful-php-web-services/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 18:01:52 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=531</guid>
		<description><![CDATA[Samisa Abeysinghe who is the director of engineering at WSO2 and one of the key leaders of the WSF/PHP project has published a book titled RESTful PHP Web Services. In Samisa&#8217;s Blog He describes the structure and the content of the book in his own words. If you are developing RESTful web services in PHP, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://samisa-abeysinghe.blogspot.com/">Samisa Abeysinghe </a>who is the director of engineering at WSO2 and one of the key leaders of the <a href="http://wso2.org/projects/wsf/php">WSF/PHP project</a> has published a book titled <a href="http://www.packtpub.com/restful-php-web-services/book">RESTful PHP Web Services</a>.</p>
<div class="wp-caption aligncenter" style="width: 550px"><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="540" height="666" /></a><p class="wp-caption-text">RESTful PHP Web Services - Samisa Abeysinghe</p></div>
<p>In <a href="http://samisa-abeysinghe.blogspot.com/2008/10/restful-php-web-services-book.html">Samisa&#8217;s Blog</a> He describes the structure and the content of the book in his own words.</p>
<p>If you are developing RESTful web services in PHP, you will find this book will be a great reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/21/book-on-restful-php-web-services/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>Writing a Simple REST and SOAP Service With PHP</title>
		<link>http://www.dimuthu.org/blog/2008/10/10/writing-a-simple-rest-and-soap-service-with-php/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/10/writing-a-simple-rest-and-soap-service-with-php/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 14:23:25 +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[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Weather]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=457</guid>
		<description><![CDATA[WSF/PHP enables you to write both REST and SOAP services in PHP from a single script. I have written about how you can expose your Database as a REST and SOAP services in few of my previous posts using the Data Service capability of WSF/PHP. But there can be situations where your service is not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wso2.org/projects/wsf/php">WSF/PHP</a> enables you to write both REST and SOAP services in PHP from a single script. I have written about how you can expose your Database as a REST and SOAP services in <a href="http://www.dimuthu.org/blog/2008/09/18/do-rest-in-php-php-restful-data-services/">few of my previous posts</a> using the Data Service capability of WSF/PHP. But there can be situations where your service is not based on a Database. For an example it can use results of some calculations, or a mashup calling other services. In that case you will prefer to write the service logic yourself. Here is how you can do it.</p>
<p>Lets think we have weather forecast data (may be from another service) and I want to make a web service using it and make it accessible via both REST and SOAP protocols.</p>
<p>In our demo service we give forecasts of temperature, humidity and some other parameters for a given date. So I expect</p>
<p>SOAP request payload as following.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;weatherReport<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;date<span style="font-weight: bold; color: black;">&gt;</span></span></span>{date}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/date<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 style="font-weight: bold; color: black;">&gt;</span></span></span>{parameter}<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;/weatherReport<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>And REST Request will be like</p>
<pre>weatherReport/{date}/forecast/{parameter}</pre>
<p>Note that here parameter can hold values like temperature, humidity or sunset-time.</p>
<p>First we declare our operation and the REST Request Mapping like this,</p>
<pre class="php"><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;">"weatherReport"</span> =&gt; <span style="color: #ff0000;">"weather_report"</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$restmap</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"weatherReport"</span> =&gt;
				<a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"HTTPMethod"</span> =&gt;<span style="color: #ff0000;">"GET"</span>,
				      <span style="color: #ff0000;">"RESTLocation"</span> =&gt; <span style="color: #ff0000;">"weatherReport/{date}/forecast/{parameter}"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;</pre>
<p>When you declare your rest mapping like above , in the service operation you will have the same request XML for both SOAP and REST form like this,</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;weatherReport<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;date<span style="font-weight: bold; color: black;">&gt;</span></span></span>{date}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/date<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 style="font-weight: bold; color: black;">&gt;</span></span></span>{parameter}<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;/weatherReport<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>So in your service logic you just handling the request in only above format. You can easily extract out the request parameters using SimpleXML functions and return the corresponding result. So you service operation would be something like this,</p>
<pre class="php"><span style="font-weight: bold; color: #000000;">function</span> weather_report<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$in_message</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

	<span style="font-style: italic; color: #808080;">// create the simple xml element for the request xml</span>
	<span style="color: #0000ff;">$request_xml</span> = <span style="font-weight: bold; color: #000000;">new</span> SimpleXMLElement<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$in_message</span>-&gt;<span style="color: #006600;">str</span><span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">// extract out the parameter and the date</span>
	<span style="color: #0000ff;">$date</span> = <span style="color: #0000ff;">$request_xml</span>-&gt;<span style="color: #006600;">date</span>;
	<span style="color: #0000ff;">$parameter</span> = <span style="color: #0000ff;">$request_xml</span>-&gt;<span style="color: #006600;">parameter</span>;

	<span style="font-style: italic; color: #808080;">// It is up to you to retrun the weather data ($result) for the requested date and parameter</span>

	<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">"&lt;response&gt;$result&lt;/response&gt;"</span>;
<span style="color: #66cc66;">}</span></pre>
<p>Finally you create the WSService object with the &#8220;operations&#8221; and &#8220;RESTMapping&#8221; and call its reply method which actually response to the requests.</p>
<pre class="php"><span style="color: #0000ff;">$service</span> = <span style="font-weight: bold; color: #000000;">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;">"RESTMapping"</span> =&gt; <span style="color: #0000ff;">$restmap</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>
<p>You just created a web service which will handle both SOAP and REST requests.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/10/writing-a-simple-rest-and-soap-service-with-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Design of the Twitter REST API</title>
		<link>http://www.dimuthu.org/blog/2008/09/29/the-design-of-the-twitter-rest-api/</link>
		<comments>http://www.dimuthu.org/blog/2008/09/29/the-design-of-the-twitter-rest-api/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 17:29:45 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=408</guid>
		<description><![CDATA[The REST API for Twitter is very simple to learn and implement. And it has a comprehensive documentation. Here is some selected operations to just to show its design. Note that here userid should be replaced with a valid twitter user id or user name and the format should be changed to the required output [...]]]></description>
			<content:encoded><![CDATA[<p>The REST API for Twitter is very simple to learn and implement. And it has a <a href="http://apiwiki.twitter.com/REST+API+Documentation">comprehensive documentation</a>.</p>
<p>Here is some selected operations to just to show its design. Note that here userid should be replaced with a valid twitter user id or user name and the format should be changed to the required output format (.xml,  json, rss, atom are possible output formats)</p>
<table border="1">
<tbody>
<tr style="background:#cccccc">
<td>Operation</td>
<td>HTTP Verb</td>
<td>URL</td>
<td>Example HTTP Request (Setting username as &#8216;dimuthu&#8217; and the output format as .xml)</td>
</tr>
<tr>
<td>Get public (all users) statuses</td>
<td>GET</td>
<td>http://twitter.com/statuses/public_timeline</td>
<td>GET <a href="http://twitter.com/statuses/public_timeline">http://twitter.com/statuses/public_timeline</a></td>
</tr>
<tr>
<td>Get a user statuses</td>
<td>GET</td>
<td>http://twitter.com/statuses/user_timeline/userid.format</td>
<td>GET <a href="http://twitter.com/statuses/user_timeline/dimuthu.xml">http://twitter.com/statuses/user_timeline/dimuthu.xml</a></td>
</tr>
<tr>
<td>Get a particular status</td>
<td>GET</td>
<td>http://twitter.com/statuses/show/statusid.format</td>
<td>GET <a href="http://twitter.com/statuses/show/938135815.xml">http://twitter.com/statuses/show/938135815.xml</a></td>
</tr>
<tr>
<td>Create a new status</td>
<td>POST</td>
<td>http://twitter.com/statuses/update.format</td>
<td>POST http://twitter.com/statuses/update.xml<br />
Authorization: Basic xxxx<br />
&#8230;&#8230;&#8230;..<br />
&lt;status&gt;my status message&lt;/status&gt;</td>
</tr>
<tr>
<td>Delete a particular status</td>
<td>DELETE/ POST</td>
<td>http://twitter.com/statuses/destroy/statusid.xml</td>
<td>DELETE http://twitter.com/statuses/destroy/939390294.xml<br />
Authorization: Basic xxxx<br />
&#8230;&#8230;&#8230;..</td>
</tr>
</tbody>
</table>
<p>After having look at this API, the first question I had was whether this API is actually RESTful. In RESTful design we expect to map a resource to a URL and do CRUD (Create, Read, Update and Delete) operations using request with different Http Verbs (POST, GET, PUT, DELETE) with that same URL. Look at my blog on <a href="http://www.dimuthu.org/blog/2008/09/27/restful-crud-data-services-demo/">RESTful CRUD Data Services Demo</a> for more clarification.</p>
<p>So if ever the API is designed following the above theory it would have been like this.</p>
<table border="1">
<tbody>
<tr style="background:#cccccc">
<td>Operation</td>
<td>HTTP Request</td>
</tr>
<tr>
<td>Get all statuses</td>
<td>GET http://twitter.com/statuses.xml</td>
</tr>
<tr>
<td>Get a particular user statuses</td>
<td>GET http://twitter.com/users/{user_id}/statuses.xml</td>
</tr>
<tr>
<td>Get a particular statuses of a user</td>
<td>GET http://twitter.com/users/{user_id}/statuses/{status_id}.xml</td>
</tr>
<tr>
<td>Crete a particular statuses of a user</td>
<td>POST http://twitter.com/users/{user_id}/statuses.xml</td>
</tr>
<tr>
<td>Update a particular statuses of a user</td>
<td>PUT http://twitter.com/users/{user_id}/statuses/{status_id}.xml</td>
</tr>
<tr>
<td>Delete a particular statuses of a user</td>
<td>DELETE http://twitter.com/users/{user_id}/statuses/{status_id}.xml</td>
</tr>
</tbody>
</table>
<p>So I think although Twitter API is really nice and easy, it is not really a RESTful API. If it was really RESTful, URLs might have been more organized so more easier to remember or predict. But still this API allows thousands of third party application to talk to the twitter, demonstrating the value of  providing web services over just providing some web pages in a website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/09/29/the-design-of-the-twitter-rest-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RESTful CRUD Data Services Demo</title>
		<link>http://www.dimuthu.org/blog/2008/09/27/restful-crud-data-services-demo/</link>
		<comments>http://www.dimuthu.org/blog/2008/09/27/restful-crud-data-services-demo/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 09:35:00 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[data services]]></category>
		<category><![CDATA[DataService]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=391</guid>
		<description><![CDATA[When you are developing Web Service for CRUD (Create, Read, Update, Delete) operations you may find it is easy to implement it as RESTful service. In this Demo on RESTful CRUD Service You can have an idea how you develop such a service with WSO2 WSF/PHP. Here we take a scenario of submitting applications (say [...]]]></description>
			<content:encoded><![CDATA[<p>When you are developing Web Service for CRUD (<strong>C</strong>reate, <strong>R</strong>ead,  <strong>U</strong>pdate, <strong>D</strong>elete) operations you may find it is easy to implement it as RESTful service. In this <a href="http://labs.wso2.org/wsf/php/resource_view.php?url=RESTFulCRUD">Demo on RESTful CRUD Service</a> You can have an idea how you develop such a service with <a href="http://wso2.org/projects/wsf/php">WSO2 WSF/PHP</a>.</p>
<p>Here we take a scenario of submitting applications (say for a school).</p>
<p>In RESTful world we map a resource to a unique URL. In this demo, application is a resource. We use the URL &#8220;application/{id}&#8221; to represent a particular application with the id {id}.</p>
<p>You can  use  HTTP verb + Resource URL touples to manipulate the resource with CRUD operations.  Here is how it is done in this particular demonstration.</p>
<table border="1">
<tbody>
<tr style="background-color:#CCCCCC;">
<td>Request format (HTTP Verb + URL)</td>
<td>Operation Semantic</td>
</tr>
<tr>
<td>POST applications/{id}</td>
<td>Create an application</td>
</tr>
<tr>
<td>GET applications/{id}</td>
<td>Get an application</td>
</tr>
<tr>
<td>PUT applications/{id}</td>
<td>Change an application</td>
</tr>
<tr>
<td>DELETE applications/{id}</td>
<td>Delete an application</td>
</tr>
</tbody>
</table>
<p>Go for the <a href="http://labs.wso2.org/wsf/php/demo.php?name=RESTFulCRUD&amp;demo=CRUDApplications/demo_client.php&amp;src=./CRUDApplications">wsf/php demo site</a>for the live demo of this service. Visit the <a href="http://labs.wso2.org/wsf/php/source_page_old.php?src=solutions%2F.%2FCRUDApplications%2Fschool_applications.php">demo service source code</a> to see how easy to implement it with WSF/PHP Data Services library.</p>
<p>I wrote a similar <a href="http://www.dimuthu.org/blog/2008/09/18/do-rest-in-php-php-restful-data-services/">blog on Data Services</a> last week to demonstrate how you design the mapping of url to different resources in a RESTful Service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/09/27/restful-crud-data-services-demo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Do REST in PHP &#8211; PHP RESTful Data Services</title>
		<link>http://www.dimuthu.org/blog/2008/09/18/do-rest-in-php-php-restful-data-services/</link>
		<comments>http://www.dimuthu.org/blog/2008/09/18/do-rest-in-php-php-restful-data-services/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 18:04:49 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[data services]]></category>
		<category><![CDATA[DataService]]></category>
		<category><![CDATA[DELETE]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[PUT]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[ROA]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WOA]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=293</guid>
		<description><![CDATA[In RESTful paradigm we give a piece of data ( or in other word &#8216;Resource&#8217;) a unique URL. And in order to manipulate data we use HTTP verbs POST/PUT (create, update), GET (read), DELETE (delete). For an example take the scenario of manipulating Students data in a high school. Here is how each operation is [...]]]></description>
			<content:encoded><![CDATA[<p>In RESTful paradigm we give a piece of data ( or in other word &#8216;Resource&#8217;) a unique URL. And in order to manipulate data we use HTTP verbs POST/PUT (create, update), GET (read), DELETE (delete). For an example<br />
take the scenario of manipulating Students data in a high school. Here is how each operation is mapped to a http request (URL + HTTP verb)</p>
<table border="1">
<tbody>
<tr style="background-color:#cccccc">
<td>HTTP request</td>
<td>Operation</td>
</tr>
<tr>
<td>POST api/students/ben</td>
<td>Create the resource (peice of data) called ben as a student. HTTP body or the url itself (e.g. api/students/ben?age=15&amp;country=xx) may contain the required information about ben</td>
</tr>
<tr>
<td>GET api/students/ben</td>
<td>Retrieve the information about ben.</td>
</tr>
<tr>
<td>PUT api/students/ben</td>
<td>Update ben</td>
</tr>
<tr>
<td>DELETE api/student/ben</td>
<td>Delete the student called &#8216;ben&#8217;.</td>
</tr>
</tbody>
</table>
<p>With the addition of all these HTTP verbs <a href="http://wso2.org/projects/wsf/php">WSO2 WSF/PHP 2.0.0</a> become a great tool for RESTful developers. Specially with the introducing Data Services library it was so easy to make your database a REST service. I m thinking of preparing a series of application to demonstrate the power of WSF/PHP with all these new features.</p>
<p>This demo -<a href="http://labs.wso2.org/wsf/php/demo.php?name=RESTfulSchool&amp;demo=RESTFulSchool/demo_client.php&amp;src=RESTFulSchool">RESTful School</a>- shows  how you map a URL to a peice of data. Here we use only the http &#8220;GET&#8221; method (which is the most to used in practicle data service).</p>
<p>Here is some description of the operations you find in there. Just check <a href="http://labs.wso2.org/wsf/php/source_page_old.php?src=solutions%2FRESTFulSchool%2Fschool_service.php"> the source code for RESTful School demo</a> to see how this is done in code level.</p>
<table border="1">
<tbody>
<tr style="background-color:#cccccc">
<td>Operation</td>
<td>URL</td>
<td>SQL Query</td>
<td>Note</td>
</tr>
<tr>
<td>Get All subjects</td>
<td>
<pre><span style="color: #ff0000;">subjects</span></pre>
</td>
<td>
<pre><span style="color: #ff0000;">SELECT subjectName, subjectTeacher FROM Subjects</span></pre>
</td>
<td>With no parameters</td>
</tr>
<tr>
<td>Get subject information From Name</td>
<td>
<pre><span style="color: #ff0000;">subjects/{name}</span></pre>
</td>
<td>
<pre><span style="color: #ff0000;">SELECT subjectName, subjectTeacher FROM Subjects where SubjectName = ?</span></pre>
</td>
<td>The single parameter feed from prepared statement syntax</td>
</tr>
<tr>
<td>Get All students</td>
<td>
<pre><span style="color: #ff0000;">students</span></pre>
</td>
<td>
<pre><span style="color: #ff0000;">SELECT * FROM Students</span></pre>
</td>
<td>Again no parameters</td>
</tr>
<tr>
<td>Get students From Name</td>
<td>
<pre><span style="color: #ff0000;">students/{name}</span></pre>
</td>
<td>Inner Query:</p>
<pre><span style="color: #ff0000;">SELECT subjectName, marks FROM Marks m, Subjects s "</span>.
        <span style="color: #ff0000;">" where m.studentId = ? and m.subjectID = s.subjectId
</span></pre>
<p>Outer Query</p>
<pre><span style="color: #ff0000;">SELECT * FROM Students where StudentName = ?</span></pre>
</td>
<td>Nested query, Inner query is called from outer query</td>
</tr>
<tr>
<td>Get Marks per Students per Subjects</td>
<td>
<pre><span style="color: #ff0000;">students/{student}/</span><span><span style="color: #ff0000;">marks/</span></span><span style="color: #ff0000;">{subject}</span></pre>
</td>
<td>
<pre><span style="color: #ff0000;">SELECT marks FROM Marks, Subjects, Students where StudentName = ?"</span>.
        <span style="color: #ff0000;">" and SubjectName = ? and Marks.subjectId = Subjects.subjectId"</span>.
        <span style="color: #ff0000;">" and Marks.studentID = Students.StudentId;</span></pre>
</td>
<td>Two parameters, and &#8216;?&#8217; in the sql query..</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/09/18/do-rest-in-php-php-restful-data-services/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WSO2 WSF/PHP 2.0.0 Just Released!</title>
		<link>http://www.dimuthu.org/blog/2008/09/12/wso2-wsfphp-200-just-released/</link>
		<comments>http://www.dimuthu.org/blog/2008/09/12/wso2-wsfphp-200-just-released/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 10:29:52 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[2.0.0]]></category>
		<category><![CDATA[data services]]></category>
		<category><![CDATA[DataService]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WS-*]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=253</guid>
		<description><![CDATA[We have been waiting for a while to do the WSF/PHP 2.0.0 release with a bundle of new features. We took time to test all the features and to make sure they are working smoothly. And it is heavily tested for the interoperability specially with .NET for WS-Security and WS-Reliable Messaging scenarios. And the newly [...]]]></description>
			<content:encoded><![CDATA[<p>We have been waiting for a while to do the <a href="http://wso2.org/projects/wsf/php">WSF/PHP 2.0.0</a> release with a bundle of new features. We took time to test all the features and to make sure they are working smoothly. And it is heavily tested for the interoperability specially with .NET for WS-Security and WS-Reliable Messaging scenarios. And the newly added Data Services library will be a great tool for the PHP community to bring their LAMP/WAMP applications to the SOA platform. WSF/PHP 2.0.0 is not just a SOAP library. It is ready for the RESTful applications as well with the improved support for HTTP verbs.</p>
<p>Here is the list of new features introduced in this release</p>
<ul>
<li>Added PKCS12 Keystore Support</li>
<li>Added Secure Conversation Support</li>
<li>Added Replay Detection Support</li>
<li>Contract First Web Services support for MTOM</li>
<li>SWA ( Soap With Attachments ) Support added</li>
<li>MTOM Attachment caching support added</li>
<li>HTTP Chunking support added</li>
<li>REST API Improved to support HTTP verbs GET,DELETE,PUT and POST</li>
<li>New PHP Data Services Solution</li>
<li>WS-RM 1.1 added</li>
</ul>
<p>Have look at the <a href="http://wso2.org/project/wsf/php/2.0.0/release-note.html">WSF/PHP 2.0.0 Official Release Note</a> for the complete feature list</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/09/12/wso2-wsfphp-200-just-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
