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

<channel>
	<title>Dimuthu's Blog &#187; tutorial</title>
	<atom:link href="http://www.dimuthu.org/tag/tutorial/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>Axis2/C ADB 2 Minutes Introduction</title>
		<link>http://www.dimuthu.org/blog/2008/09/03/axis2c-adb-2-minitue-introduction/</link>
		<comments>http://www.dimuthu.org/blog/2008/09/03/axis2c-adb-2-minitue-introduction/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 14:14:27 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[2 minutes guide]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[codegen]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[wsdl2c]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml schema]]></category>
		<category><![CDATA[2 minutes]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=204</guid>
		<description><![CDATA[Building and Traversing XML are regular tasks for any Web Service developer. We may use DOM, AXIOM or even simple String manipulation functions to do that. Normally this takes a lot of time and effort. And if we are coding in &#8216;C&#8217; it become more tedious as string manipulation in &#8216;C&#8217; is not that straight [...]]]></description>
			<content:encoded><![CDATA[<p>Building and Traversing XML are regular tasks for any Web Service developer. We may use DOM, AXIOM or even simple String manipulation functions to do that. Normally this takes a lot of time and effort. And if we are coding in &#8216;C&#8217; it become more tedious as string manipulation in &#8216;C&#8217; is not that straight forward.</p>
<p>What ADB does is it generates a set of &#8216;C&#8217; functions specially for our XML Schema to build and traverse the XML.<br />
Say you have the following XML Schema. (You need to have it inside a WSDL to generate the code).</p>
<pre>        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:schema</span> <span style="color: #000066;">targetNamespace</span>=<span style="color: #ff0000;">"http://dimuthu.org/adb/demo/2008/sept"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-style: italic; color: #808080;">&lt;!-- demonstrating element--&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"myDemo"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"demo1"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xs:int"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"demo2"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xs:string"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xs:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xs:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xs:element<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xs:schema</span><span style="font-weight: bold; color: black;">/&gt;</span></span></pre>
<p>For this particular element there will be one adb type (adb_myDemo_t), one source (adb_myDemo.c) and one header (adb_myDemo.h) are generated. Don&#8217;t ever look at the source file (unless you want to hack it) just go through the header, it will have all the function you need to manipulate your ADB.</p>
<p>It will have following set of functions,</p>
<pre>To create and free the object
<ul>
<li>adb_myDemo_create</li>
<li>adb_myDemo_free</li>
</ul>

Getters and Setters to manipulate Data
<ul>
<li>adb_myDemo_get_demo1</li>
<li>adb_myDemo_set_demo1</li>
<li>adb_myDemo_get_demo2</li>
<li>adb_myDemo_set_demo2</li>
</ul>

Build and Parse XML
<ul>
<li>adb_myDemo_serialize</li>
<li>adb_myDemo_deserialize</li>
</ul>
</pre>
<p>First we will check how to build a simple XML using an ADB object.</p>
<pre>    adb_myDemo_t *mydemo = adb_myDemo_create<span style="color: #66cc66;">(</span>env<span style="color: #66cc66;">)</span>;
    adb_myDemo_set_demo1<span style="color: #66cc66;">(</span>mydemo, env, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">)</span>; <span style="font-style: italic; color: #808080;">/* some arbitrary value */</span>
    adb_myDemo_set_demo2<span style="color: #66cc66;">(</span>mydemo, env, <span style="color: #ff0000;">"some arbitrary string"</span><span style="color: #66cc66;">)</span>;
    axiom_t *xml = adb_myDemo_serialize<span style="color: #66cc66;">(</span>mydemo, env, <span style="font-weight: bold; color: #000000;">NULL</span>, <span style="font-weight: bold; color: #000000;">NULL</span>, AXIS2_TRUE, <span style="font-weight: bold; color: #000000;">NULL</span>, <span style="font-weight: bold; color: #000000;">NULL</span><span style="color: #66cc66;">)</span>;</pre>
<p>So now we have the AXIOM representation of the XML which we just build using ADB.</p>
<pre><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ns0:myDemo</span> xmlns:ns0=<span style="color: #ff0000;">"http://dimuthu.org/adb/demo/2008/sept"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ns0:demo1<span style="font-weight: bold; color: black;">&gt;</span></span></span>3<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ns0:demo1<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ns0:demo2<span style="font-weight: bold; color: black;">&gt;</span></span></span>some arbitrary string<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ns0:demo2<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ns0:myDemo<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>Anyway ADB is easier when you want to navigate through an XML. (you can read data randomly as you preferred). Here we starting from the AXIOM representation of our XML.</p>
<pre>      adb_myDemo_t *mydemo= adb_myDemo_create<span style="color: #66cc66;">(</span> env<span style="color: #66cc66;">)</span>;
      adb_myDemo_deserialize<span style="color: #66cc66;">(</span>mydemo, env, &amp;xml, <span style="font-weight: bold; color: #000000;">NULL</span>, AXIS2_FALSE<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>
      <span style="color: #993333;">int</span> demo1 = adb_myDemo_get_demo1<span style="color: #66cc66;">(</span>mydemo, env<span style="color: #66cc66;">)</span>;
      <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"My Demo1 is: %d<span style="font-weight: bold; color: #000099;">\\</span>n"</span>, demo1<span style="color: #66cc66;">)</span>;
      axis2_char_t *demo2 = adb_myDemo_get_demo2<span style="color: #66cc66;">(</span>mydemo, env<span style="color: #66cc66;">)</span>;
      <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"My Demo2 is: %s<span style="font-weight: bold; color: #000099;">\\</span>n"</span>, demo2<span style="color: #66cc66;">)</span>;</pre>
<p>I have printed the Data contained in the XML with the help of ADB objects.</p>
<p>In ordre to download the Codegen tool with ADB you have to download the <a href="http://ws.apache.org/axis2/download.cgi">Axis2/Java package</a>.</p>
<p>If you want to learn more about ADB, Just go through <a href="http://www.dimuthu.org/blog/2008/07/21/axis2c-adb-codegen-wsdl2c-tutorial-resources/">more Axis2/C Codegen / ADB resources </a>which I have blogged few weeks ago.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/09/03/axis2c-adb-2-minitue-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nested Queries with PHP Data Services</title>
		<link>http://www.dimuthu.org/blog/2008/08/04/nested-queries-with-php-data-services/</link>
		<comments>http://www.dimuthu.org/blog/2008/08/04/nested-queries-with-php-data-services/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 19:33:46 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[DataServices]]></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[guide]]></category>
		<category><![CDATA[nested queires]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=78</guid>
		<description><![CDATA[We use the term &#8216;DataService&#8217; when we expose a database as a web service. WSO2 has a separate product for the DataService space which was earlier shipped bundled with WSAS. There you write a configuration xml explaining what data to be exposed in your database and drop it in the WSAS java app server and [...]]]></description>
			<content:encoded><![CDATA[<p>We use the term &#8216;DataService&#8217; when we expose a database as a web service. WSO2 has a <a href="http://wso2.org/projects/solutions/data-services/java">separate product</a> for the DataService space which was earlier shipped bundled with WSAS. There you write a configuration xml explaining what data to be exposed in your database and drop it in the WSAS java app server and you get the DataServices deployed without much effort. Couple of months ago we published <a href="http://labs.wso2.org/wsf/php/resource_view.php?url=DataServices">PHP DataServices</a> library that allow you do deploy Your DataService within a popular LAMP or WAMP stack. With the WSF/PHP 2.0.0 release, you can have the PHP DataService library bundled with the release, hopefully within next couple of weeks.</p>
<p>One of the main problem DataService developers face is how to design an elegant web service API that will provide the requested information from a row database straightaway. Because when we normalize a database, the very closely related data are spread in different tables just keeping the association with foreign keys. So in order to retrieve the useful information database developers have to write multiple queries to the database. Is that same with DataServices?, Do you have to write multiple web service requests to return some useful data?</p>
<p>No. You don&#8217;t. You have Nested Queries to save you. With nested queries you can configure your DataServices, so all the relevent information can be extracted and send as a single SOAP message. I will take a demonstration to explain this.</p>
<p>Say you are working for a company that manufacture or sell electrical equipments, say TVs. And your boss is asking you to prepare a whole list of customers who ordered good from them. He want order information (like order date, status of the order) plus the name of the customers in the list.</p>
<p>Here is the table structure that you have.<br />
<strong>Orders</strong></p>
<table border="1" width="300">
<tbody>
<tr>
<td>ORDERNUMBER</td>
<td>ORDERDATE</td>
<td>STATUS</td>
<td>CUSTOMERID</td>
</tr>
</tbody>
</table>
<p><strong>Customers</strong></p>
<table border="1" width="300">
<tbody>
<tr>
<td>CUSTOMERID</td>
<td>CUSTOMERNAME</td>
</tr>
</tbody>
</table>
<p>From this you have to find a list of orders with order date, status (available in Orders table) and ordered customer information available in Customers table. As you may seen you have to query both the tables to get the required data.</p>
<p>First you have to decide a service operation that you going to expose as a web service. Operation is uniquely identified by its name. We will give our operation the name &#8220;getOrders&#8221;. In fact in our PHP Data Service API we treat a Operation same as a query. In general operation/query has following properties associated with it. Note for the complete API please check <a href="http://wso2.org/wiki/display/wsfphp/API+for+Data+Services+Revised">this Oxygen Tank Page</a>.<br />
<strong>Properties of Data Service Operation/Query</strong></p>
<table border="1" width="100%">
<tbody>
<tr>
<td>inputFormat</td>
<td>This is the map of input element or input parameter to the corresponding type. For our operation there is no input. So we are not setting it here.</td>
</tr>
<tr>
<td>outputFormat</td>
<td>This is a little tricky option. You have to set several configuration under this.</p>
<table border="1">
<tbody>
<tr>
<td>resultElement</td>
<td>The name of the wrapper response element. We will give the name &#8220;<em>Orders</em>&#8221; here.</td>
</tr>
<tr>
<td>rowElement</td>
<td>The name we give to wrap the each row of the result. If we give this value something like &#8220;<em>Order</em>&#8220;, then the result xml will be like,</p>
<pre><span><span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;orders</span></span></span></span><span style="font-weight: bold; color: black;">&gt;</span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;order<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    order 1 details
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/order<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;order<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    next order details
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/order<span style="font-weight: bold; color: black;">&gt;</span></span></span>

  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;order<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    etc
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/order<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/orders<span style="font-weight: bold; color: black;">&gt;</span>
</span></span></pre>
</td>
</tr>
<tr>
<td>elements</td>
<td>The name of elements that is going to be in the response XML map to the real names of columns in the actual query result.<br />
For an example if I give this the following value.</p>
<pre><span style="color: #000066;">array</span><span style="color: #66cc66;">(</span><span><span style="color: #ff0000;"><span style="font-weight: bold; color: #000099;">"</span></span></span><span style="color: #ff0000;">Order_number<span style="font-weight: bold; color: #000099;">"</span> =&gt; <span style="font-weight: bold; color: #000099;">"</span>ORDERNUMBER<span style="font-weight: bold; color: #000099;">"</span>,
      <span style="font-weight: bold; color: #000099;">"</span>Order_date<span style="font-weight: bold; color: #000099;">"</span> =&gt; <span style="font-weight: bold; color: #000099;">"</span>ORDERDATE<span style="font-weight: bold; color: #000099;">"</span>,
      <span style="font-weight: bold; color: #000099;">"</span>Status<span style="font-weight: bold; color: #000099;">"</span> =&gt; <span style="font-weight: bold; color: #000099;">"</span>STATUS<span style="font-weight: bold; color: #000099;">"</span>);</span></pre>
<p>The portion of the response will be like this,</p>
<pre><span><span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;order</span></span></span></span><span style="font-weight: bold; color: black;">&gt;</span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Order_number<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    3
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Order_number<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Order_date<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    2008-06-09
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Order_date<span style="font-weight: bold; color: black;">&gt;</span></span></span>

  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Status<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    Shipped
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Status<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/order<span style="font-weight: bold; color: black;">&gt;</span>
</span></span></pre>
</td>
</tr>
<tr>
<td>queries</td>
<td>Array of queries, (The correct term is nested queries). So here you can set the response to be the result of another query. In fact in order to retrieve the customer name for the corresponding order we are going to write a nested query. Just think a operation that take the customerId as a parameter and return the customer data.</p>
<pre>getCustomer<span style="color: #66cc66;">(</span>customerId<span style="color: #66cc66;">)</span></pre>
<p>You have to build this operation/query from the stat as we are just building the &#8216;getOrders&#8217; query</td>
</tr>
<tr>
<td>attributes,  texts, elementsOrder</td>
<td>Some other configuration options. we are not using it in here, but by the name you can have an idea what they are for.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>sql</td>
<td>The standard sql query corresponding to the operation. In our case it is</p>
<pre><span style="font-weight: bold; color: #993333;">SELECT</span> o.ORDERNUMBER,o.ORDERDATE, o.<span style="font-weight: bold; color: #993333;">STATUS</span>,o.CUSTOMERNUMBER <span style="font-weight: bold; color: #993333;">FROM</span> ds.Orders o</pre>
</td>
</tr>
<tr>
<td>inputMapping</td>
<td>Finally this describe how the names of the input elements are mapped to the names of input parameters. Since &#8216;getOrders&#8217; operation doesn&#8217;t have input parameters, this is not going to be used in this particular situation.</td>
</tr>
</tbody>
</table>
<p>So as I described in the queries section you have to write the whole thing for the getCustomer operation as well.</p>
<pre><span style="color: #0000ff;">$getCustomer</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    "inputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"customerNumber" =&gt; "INTEGER"<span style="color: #66cc66;">)</span>,
    "outputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>

            "resultElement" =&gt; "Customers",
            "rowElement" =&gt; "Customer",
            "elements" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"name" =&gt; "CUSTOMERNAME"<span style="color: #66cc66;">)</span>
            <span style="color: #66cc66;">)</span>,
    "sql" =&gt; "select c.CUSTOMERNAME from ds.Customers c where c.CUSTOMERNUMBER = ?",
    "inputMapping" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"CUSTOMERNUMBER" =&gt; "customerNumber"<span style="color: #66cc66;">)</span>

    <span style="color: #66cc66;">)</span>;</pre>
<p>And here is the getOrders operation/query that actually use the getCustomer as a part of it.</p>
<pre><span style="color: #0000ff;">$getOrders</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    "outputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
        "resultElement" =&gt; "Orders",
        "rowElement" =&gt; "Order",
        "elements" =&gt;  <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>

            "Order_number" =&gt; "ORDERNUMBER",
            "Order_date" =&gt; "ORDERDATE",
            "Status" =&gt; "STATUS"<span style="color: #66cc66;">)</span>,
         "queries" =&gt;  <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$getCustomer</span><span><span style="color: #66cc66;">)
</span></span>  <span style="color: #66cc66;">       )</span>,
    "sql" =&gt; "select c.CUSTOMERNAME from ds.Customers c where c.CUSTOMERNUMBER = ?"
    <span style="color: #66cc66;">)</span>;</pre>
<p>Then we will to define the operations array which we are going feed to the DataService class. Note that now we have two operations <em>getOrders</em> and <em>getCustomer</em>. From that I used getCustomer to help the building of <em>getOrders</em>. And I don&#8217;t want to publish <em>getCustomer</em> as a separate operation. Simply the boss doesn&#8217;t ask for that operation <img src='http://www.dimuthu.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . So my operation map is like this,</p>
<pre><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>"getOrders" =&gt; <span style="color: #0000ff;">$getOrders</span><span style="color: #66cc66;">)</span>;</pre>
<p>This operation map will be given as a constructor argument of DataService class. If you are familiar with WSF/PHP WSService class, there is no much different between these two classes. You can give all the options available in the <a href="http://wso2.org/project/wsf/php/1.3.2/docs/api_content.html#service">WSService</a> class to the DataService class. Say you want to encrypt the messages, just use the &#8220;policy&#8221; and the &#8220;securityToken&#8221; options. So with DataService class you have the luxury of using WS-Security as well as WS-Reliable Messaging for free.</p>
<p>To finish this post I will put the complete code for the above scenario. You can check the same service option in action in the  <a href="http://labs.wso2.org/wsf/php/demo.php?name=DataServices&amp;demo=DataServices/samples/demo.php&amp;src=DataServices/">WSF/PHP Demo site</a> (Try the demo4).</p>
<pre><span style="font-weight: bold; color: #000000;">&lt;?php</span>
<span style="font-style: italic; color: #808080;">// include the DataService library.</span>
<span style="font-style: italic; color: #808080;">// NOTE: this path is valid only from wsf/php 2.0.0</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">(</span>"wso2/DataServices/DataService.php"<span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// set the configurations</span>
<span style="color: #0000ff;">$config</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"db" =&gt; "<a href="http://www.php.net/mysql"><span style="color: #000066;">mysql"</span></a>,
   "username" =&gt; "dimuthu",
   "password" =&gt; "thiswillnotbeasecretanymore",
   "dbname" =&gt; "ds",
   "dbhost" =&gt; "localhost"<span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// getCustomer Query - this used by the getOrders query/operation</span>
<span style="color: #0000ff;">$getCustomer</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    "inputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"customerNumber" =&gt; "INTEGER"<span style="color: #66cc66;">)</span>,
    "outputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>

            "resultElement" =&gt; "Customers",
            "rowElement" =&gt; "Customer",
            "elements" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"name" =&gt; "CUSTOMERNAME"<span style="color: #66cc66;">)</span>
            <span style="color: #66cc66;">)</span>,
    "sql" =&gt; "select c.CUSTOMERNAME from ds.Customers c where c.CUSTOMERNUMBER = ?",
    "inputMapping" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"CUSTOMERNUMBER" =&gt; "customerNumber"<span style="color: #66cc66;">)</span>

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

<span style="font-style: italic; color: #808080;">// The operation/query getOrders - Read the complete blog to see what </span>
<span style="font-style: italic; color: #808080;">// each of these option stand for</span>
<span style="color: #0000ff;">$getOrders</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
    "outputFormat" =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>
        "resultElement" =&gt; "Orders",
        "rowElement" =&gt; "Order",
        "elements" =&gt;  <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>

            "Order_number" =&gt; "ORDERNUMBER",
            "Order_date" =&gt; "ORDERDATE",
            "Status" =&gt; "STATUS"<span style="color: #66cc66;">)</span>,
         "queries" =&gt;  <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$getCustomer</span><span><span style="color: #66cc66;">)
</span></span>  <span style="color: #66cc66;">       )</span>,
    "sql" =&gt; "select c.CUSTOMERNAME from ds.Customers c where c.CUSTOMERNUMBER = ?"
    <span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// operation array</span>
<span style="color: #0000ff;">$operations</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"getOrders" =&gt; <span style="color: #0000ff;">$getOrders</span><span style="color: #66cc66;">)</span>;

<span style="font-style: italic; color: #808080;">// create the DataService object and reply</span>
<span style="color: #0000ff;">$ds</span> = <span style="font-weight: bold; color: #000000;">new</span> DataService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span>"operations" =&gt; <span style="color: #0000ff;">$operations</span>,
          "config" =&gt; <span style="color: #0000ff;">$config</span>,
          "serviceName" =&gt; NextedQuerySample<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$ds</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

<span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/08/04/nested-queries-with-php-data-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Axis2/C ADB Codegen (WSDL2C) Tutorial + Resources</title>
		<link>http://www.dimuthu.org/blog/2008/07/21/axis2c-adb-codegen-wsdl2c-tutorial-resources/</link>
		<comments>http://www.dimuthu.org/blog/2008/07/21/axis2c-adb-codegen-wsdl2c-tutorial-resources/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 02:03:26 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[adb]]></category>
		<category><![CDATA[axis2/c]]></category>
		<category><![CDATA[codegen]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsdl2c]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WSLD2C]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=18</guid>
		<description><![CDATA[Here are some list of links that you may find useful to start working with Axis2/C ADB Codegen tool. Building Axis2/C Web Services with the help of Axis2/Java Tools (Tutorial) Codegen + ADB Samples (SVN) 20+ Test cases, how different schemas are constructed in ADB/C Helper tools to generate demo codes for Axis2/C ADB generated [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some list of links that you may find useful to start working with Axis2/C ADB Codegen tool.</p>
<ol>
<li><a title="Axis2/C ADB tutorial" href="http://wso2.org/library/3534">Building Axis2/C Web Services with the help of Axis2/Java Tools (Tutorial)</a></li>
<li><a title="Codegen + ADB Samples from SVN" href="http://svn.apache.org/repos/asf/webservices/axis2/trunk/c/samples/codegen/">Codegen + ADB Samples (SVN)</a></li>
<li><a title="Axis2/C ADB Test Cases" href="http://people.apache.org/~dimuthu/leisure/1_dec/wsdl2ctests.tar.bz2">20+ Test cases, how different schemas are constructed in ADB/C</a></li>
<li><a title="Axis2/C codegen helper tool blog" href="http://dimuthuc.wordpress.com/2007/12/01/axis2c-codegen-helper-tools/">Helper tools to generate demo codes for Axis2/C ADB generated code (Blog)<br />
</a></li>
<li><a title="Axis2/C Codegen new features Blog" href="http://dimuthuc.wordpress.com/2007/11/16/axis2c-codegen-new-features/">How Axis2/C ADB Codegen support nillable and minOccurs=0 (Blog)<br />
</a></li>
<li><a title="Blog on Simple Type List Support" href="http://dimuthuc.wordpress.com/2007/12/31/last-jira-for-the-year-2007/">Simple Type List Support (Blog)</a></li>
<li><a title="Overview of Axis2/C ADB" href="http://wsaxc.blogspot.com/2007/06/using-wsdl2c-tool.html">Overview of using Axis2/C ADB (Blog)</a></li>
<li><a title="Little Howto base64 xmime" href="http://www.nabble.com/adb-with-base64Binary-and-xmime.xsd---little-howto-td12900422.html">adb with base64Binary and xmime.xsd &#8211; little howto (Mail)</a></li>
<li><a title="Developer list archieves" href="http://www.nabble.com/forum/Search.jtp?query=wsdl2c+OR+codegen+and+not+jira&amp;sort=date&amp;local=y&amp;forum=227&amp;daterange=0">Latest developers discussion on Axis2/C codegen tool (Mail)</a></li>
<li><a title="Past user list archieves" href="http://www.nabble.com/forum/Search.jtp?query=wsdl2c+or+codegen&amp;sort=date&amp;local=y&amp;forum=228&amp;daterange=0">Past User inquiries on Axis2/C Adb Codegen tool (Mail)</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/07/21/axis2c-adb-codegen-wsdl2c-tutorial-resources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

