<?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; demo</title>
	<atom:link href="http://www.dimuthu.org/tag/demo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 21 Dec 2011 05:39:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
  <link>http://www.dimuthu.org</link>
  <url>http://www.dimuthu.org/favicon.ico</url>
  <title>Dimuthu's Blog</title>
</image>
		<item>
		<title>DEMO on a SOAP and REST Client with PHP</title>
		<link>http://www.dimuthu.org/blog/2008/10/17/demo-on-a-soap-and-rest-client-with-php/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/17/demo-on-a-soap-and-rest-client-with-php/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 16:50:57 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[REST]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WSClient]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=478</guid>
		<description><![CDATA[Last week I wrote a how to on Writing a SOAP and REST Service with PHP. It shows how to write a single script that enables the SOAP and REST web services interfaces using WSF/PHP. Today I&#8217;m going to show you how you can use WSF/PHP to write clients in both SOAP and REST form. [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a <a href="http://www.dimuthu.org/blog/2008/10/10/writing-a-simple-rest-and-soap-service-with-php/">how to on Writing a SOAP and REST Service with PHP</a>. It shows how to write a single script that enables the SOAP and REST web services interfaces using <a href="http://wso2.org/projects/wsf/php">WSF/PHP</a>. Today I&#8217;m going to show you how you can use WSF/PHP to write clients in both SOAP and REST form.</p>
<p>For that I use the <a href="http://labs.wso2.org/wsf/php/resource_view.php?url=AmazonClient">Amazon Client Demo</a> hosted in the <a href="http://labs.wso2.org/wsf/php">PHP Web Services Demo Site</a>. With this demo you can do shopping with Amazon using their web services API. It uses <a href="http://labs.wso2.org/wsf/php/source_page_old.php?src=solutions%2FAmazon%2FAmazonClient.php">a php library (AmazonClient.php) </a>that allows us to connect Amazon using SOAP or REST libraries.</p>
<p>You can see in <a href="http://labs.wso2.org/wsf/php/source_page_old.php?src=solutions%2FAmazon%2FAmazonClient.php">the library code</a> It is using different values for &#8220;useSOAP&#8221; argument depending on what form of messaging we like to use. Amazon SOAP service uses the SOAP 1.1 and the REST service uses the &#8220;GET&#8221; HTTP method for messaging. We can configure these details as mentioned in the following table.</p>
<table border="1px" style="width:500px">
<tbody>
<tr style="background: #666666">
<td>REST</td>
<td>SOAP</td>
</tr>
<tr>
<td>
<pre class="php"><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
      <span style="color: #ff0000;">"to"</span>=&gt;self::<span style="color: #006600;">AMAZON_REST_ENDPOINT</span>,
      <span style="color: #ff0000;">"HTTPMethod"</span>=&gt;<span style="color: #ff0000;">"GET"</span>,
      <span style="color: #ff0000;">"useSOAP"</span> =&gt; <span style="font-weight: bold; color: #000000;">FALSE</span><span style="color: #66cc66;">)</span></pre>
</td>
<td>
<pre class="php"><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
      <span style="color: #ff0000;">"to"</span>=&gt;self::<span style="color: #006600;">AMAZON_SOAP_ENDPOINT</span>,
      <span style="color: #ff0000;">"useSOAP"</span> =&gt; <span style="color: #ff0000;">"1.1"</span>,
      <span style="color: #ff0000;">"action"</span> =&gt; <span style="color: #ff0000;">"http://soap.amazon.com"</span><span style="color: #66cc66;">)</span></pre>
</td>
</tr>
</tbody>
</table>
<p>Since Amazon requires different request messages for SOAP and REST services, we have to create them separately depending on the request type. But the response returns by the service is same in both cases so we can handle it using the same code.</p>
<p>Here is how ItemLookup operation of the Amazon service is written within the above mentioned constrains.</p>
<pre class="php">    <span style="font-style: italic; color: #808080;">/**
     * ItemLookup
     * @param $ASIN Amaxon Item Id
     * @return associate array consist of the response parameters
     */</span>
    <span style="font-weight: bold; color: #000000;">public</span> <span style="font-weight: bold; color: #000000;">function</span> ItemLookup<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$ASIN</span><span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">is_soap</span><span style="color: #66cc66;">)</span>
        <span style="color: #66cc66;">{</span>
             <span style="color: #0000ff;">$req_payload</span> = &lt;&lt;&lt;XML
                &lt;ItemLookup xmlns=<span style="color: #ff0000;">"http://webservices.amazon.com/AWSECommerceService/2007-10-29"</span>&gt;
                    &lt;SubscriptionId&gt;<span style="color: #66cc66;">{</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">amazon_key</span><span style="color: #66cc66;">}</span>&lt;/SubscriptionId&gt;
                    &lt;ResponseGroup&gt;Medium&lt;/ResponseGroup&gt;
                    &lt;Request&gt;
                        &lt;ItemId&gt;<span style="color: #66cc66;">{</span><span style="color: #0000ff;">$ASIN</span><span style="color: #66cc66;">}</span>&lt;/ItemId&gt;
                        &lt;ReviewPage&gt;<span style="color: #cc66cc;">1</span>&lt;/ReviewPage&gt;
                    &lt;/Request&gt;
                &lt;/ItemLookup&gt;
XML;
        <span style="color: #66cc66;">}</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #66cc66;">{</span>
             <span style="color: #0000ff;">$req_payload</span> = &lt;&lt;&lt;XML
                &lt;ItemLookup xmlns=<span style="color: #ff0000;">"http://webservices.amazon.com/AWSECommerceService/2007-10-29"</span>&gt;
                    &lt;SubscriptionId&gt;<span style="color: #66cc66;">{</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">amazon_key</span><span style="color: #66cc66;">}</span>&lt;/SubscriptionId&gt;
                    &lt;Service&gt;AWSECommerceService&lt;/Service&gt;
                    &lt;ResponseGroup&gt;Large&lt;/ResponseGroup&gt;
                    &lt;Operation&gt;ItemLookup&lt;/Operation&gt;
                    &lt;ItemId&gt;<span style="color: #66cc66;">{</span><span style="color: #0000ff;">$ASIN</span><span style="color: #66cc66;">}</span>&lt;/ItemId&gt;
                    &lt;ReviewPage&gt;<span style="color: #cc66cc;">1</span>&lt;/ReviewPage&gt;
                &lt;/ItemLookup&gt;
XML;
        <span style="color: #66cc66;">}</span>

        <span style="color: #0000ff;">$ret_message</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">request</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$req_payload</span><span style="color: #66cc66;">)</span>;

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

        <span style="color: #0000ff;">$res</span> = <span style="color: #0000ff;">$simplexml</span>;

        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$res</span>;
    <span style="color: #66cc66;">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/17/demo-on-a-soap-and-rest-client-with-php/feed/</wfw:commentRss>
		<slash:comments>2</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>
	</channel>
</rss>

