<?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>Jonathan Wijaya Loe&#039;s blog &#187; Tutorial</title>
	<atom:link href="http://blog.jloe.net/category/technology/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jloe.net</link>
	<description>A blog about technology blogging, tips and tricks, troubleshooting, and step by step tutorial with specialties in Microsoft .NET, C#, Zend, and PHP. Also includes wonderful and inspiring stories and jokes.</description>
	<lastBuildDate>Mon, 02 May 2011 00:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Read Remote Content or File using Zend</title>
		<link>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=read-remote-content-or-file-using-zend</link>
		<comments>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/#comments</comments>
		<pubDate>Tue, 05 May 2009 11:33:00 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=333</guid>
		<description><![CDATA[Today I was looking around for sample to read a remote file in PHP or even better using Zend. Well there are quite a few good samples that demonstrate the use of native PHP functions: fopen, file_get_contents, or curl but I hardly find examples using Zend. Perhaps it&#8217;s just not my luck. But the good [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was looking around for sample to read a remote file in PHP or even better using Zend. Well there are quite a few good samples that demonstrate the use of native PHP functions: fopen, file_get_contents, or curl but I hardly find examples using Zend. Perhaps it&#8217;s just not my luck. But the good thing is I managed to write my own code using Zend upon reading through few samples from <a href="http://framework.zend.com/manual/en/zend.controller.response.html">Zend documentation</a>. Here goes the code.<span id="more-333"></span></p>
<pre name="code" class="php">
/**
 * Read the remote file and send the content as the response
 *
 * @author Jonathan Loe
 * @date   May 05 2009
 */
protected function readAndSendRemoteContent( $url )
{
  // Set the configuration parameters
  $config = array( 'adapter' =&gt; 'Zend_Http_Client_Adapter_Socket' );

  // Instantiate a client object
  $client = new Zend_Http_Client( $url, $config );
  $response = $client-&gt;request();

  $this-&gt;getResponse()
    -&gt;setHeader( 'Content-type', $response-&gt;getHeader( 'Content-type' ) )
    -&gt;appendBody( $response-&gt;getRawBody() )
    -&gt;sendResponse();
}
</pre>
<p>First line of code is to set the adapter as Zend_Http_Client_Adapter_Socket. Next line is to specify the remote url along with the adapter set in the config and make the request. My last code is to send whatever was received and send it to the client as a response with the same &#8216;Content-type&#8217;. $this refers to the instance of the Zend controller class.</p>
<p>It&#8217;s that simple hey? <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS: If you&#8217;re looking for other samples which demonstrate use of the native functions. Here are a few links you may be interested in.</p>
<p>Links:</p>
<ul>
<li><a href="http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx" target="_blank">Reading a Remote File Using PHP</a></li>
<li><a href="http://www.humanumbrella.com/2007/12/08/how-to-download-a-remote-file-in-php-and-then-save-it/" target="_blank">How to download a remote file in php and then save it</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Excerpt in WordPress</title>
		<link>http://blog.jloe.net/2009/04/25/display-excerpt-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=display-excerpt-in-wordpress</link>
		<comments>http://blog.jloe.net/2009/04/25/display-excerpt-in-wordpress/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 15:43:41 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=229</guid>
		<description><![CDATA[Displaying excerpt on your blog especially on your front page is preferable since it provides a fast loading time for your readers, especially those who would like to skim through your posts but not to wait for the front page to load some long and undesirable posts. Not only that, if you use Google Analytics [...]]]></description>
			<content:encoded><![CDATA[<p>Displaying excerpt on your blog especially on your front page is preferable since it provides a fast loading time for your readers, especially those who would like to skim through your posts but not to wait for the front page to load some long and undesirable posts.</p>
<p>Not only that, if you use <a title="Google service that helps to track page visits" href="http://www.google.com/analytics" target="_blank">Google Analytics</a> to help you track and analyse your site hits, this definitely will help you identify which posts are more interesting to your readers and at the same time increase the number of page views.</p>
<p>I found a few good articles on how to enable this, which may be of use for your blog. These articles give very clear and complete information on how to display excerpt on your front page and other pages as well.</p>
<p>Here are the links:</p>
<ul>
<li><a title="Display Post Excerpts Only in WordPress" href="http://lorelle.wordpress.com/2006/07/19/display-post-excerpts-only-in-wordpress/" target="_blank">Display Post Excerpts Only in WordPress</a></li>
<li><a title="Template Tags/the excerpt" href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">Template Tags/the excerpt</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/25/display-excerpt-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start SOAP with Zend Framework</title>
		<link>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=start-soap-with-zend-framework</link>
		<comments>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 01:37:51 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[wampserver]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[wsdl]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend_soap_client]]></category>
		<category><![CDATA[zend_soap_server]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=139</guid>
		<description><![CDATA[SOAP? Hang on.. This is not the soap you probably first think of from your daily life. This is the SOAP in Information Technology term. Sorry but don't mean to discriminate anyone out there ;)]]></description>
			<content:encoded><![CDATA[<p>SOAP? Hang on.. This is not the soap you probably first think of from your daily life. This is the SOAP in Information Technology term. Sorry but don&#8217;t mean to discriminate anyone out there <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For readers who have no idea what SOAP is. Here&#8217;s a short explanation about SOAP as defined by <a title="What is SOAP?" href="http://searchsoa.techtarget.com/sDefinition/0,,sid26_gci214295,00.html" target="_blank">TechTarget</a>.</p>
<blockquote><p>SOAP (Simple Object Access Protocol) is a way for a program running in one kind of operating system (such as Windows 2000) to communicate with a program in the same or another kind of an operating system (such as Linux) by using the World Wide Web&#8217;s Hypertext Transfer Protocol (HTTP)and its Extensible Markup Language (XML) as the mechanisms for information exchange.</p></blockquote>
<p>Here I will share my step-by-step guide on how to start your SOAP application using PHP and Zend as your Model View Controller (MVC) framework. First, I have the following application and framework installed. But I will not explain in detail about them in this post.</p>
<ul>
<li><a title="WampServer" href="http://www.wampserver.com/" target="_blank">WampServer</a></li>
<li><a title="Zend Framework" href="http://framework.zend.com/download" target="_blank">Zend Framework 1.7.5</a></li>
</ul>
<p>To start, first you need to enable a php extension called <em>php_soap</em>. In WampServer, this module has been pre-installed but you need to enable the module by the following steps.</p>
<ol>
<li>Click WampServer icon on the tray.</li>
<li>Select PHP &gt; PHP Extension.</li>
<li>And finally click php_soap to enable it.</li>
</ol>
<p>Then, we create a simple class called <em>Models_Writer</em> which has a function <em>write</em> that returns the specified string to the calling function.</p>
<pre name="code" class="php">
class Models_Writer
{
  /**
   * Return the specified text
   *
   * @param string $string
   * @return string
   */
  public function write( $string )
  {
    return $string;
  }
}
</pre>
<p>Followed by a simple action function called <em>wsdlAction</em> which renders generated <em>WSDL</em> for the class <em>Models_Writer</em> using <em>Zend_Soap_AutoDiscover</em>. Hey hey stop! what the heck is <em>WSDL</em>?. In short,</p>
<blockquote><p>WSDL or Web Services Description Language is an XML-based language that provides a model for describing Web services.</p></blockquote>
<p>Follow this <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language">link</a> on wikipedia to help you along with what exactly is WSDL.</p>
<p>Moving on&#8230;</p>
<pre name="code" class="php">
/**
 * Render the WSDL
 */
public function wsdlAction()
{
  $wsdl = new Zend_Soap_AutoDiscover();
  $wsdl-&gt;setUri( APP_URL . '/index/' );
  $wsdl-&gt;setClass( 'Models_Writer' );
  $wsdl-&gt;handle();
  exit;
}
</pre>
<p><!--adsense#az-edeal-->As shown on line 7, <em>APP_URL</em> is to be replaced with the url of the application (ie. http://localhost/). You may define <em>APP_URL</em> inside <em>bootstrap.php</em> for global use. Function <em>setUri</em> is used to define the url used as the server. In this example, the <em>indexAction</em> is used to serve as the Soap server. And to verify the generated <em>WSDL</em> is correct, use your browser and type http://localhost/index/wsdl<strong><span style="text-decoration: underline;">/</span></strong> with the assumption that all Action functions in this example will be coded inside <em>IndexController</em> class. This url should returns with the correct <em>WSDL</em>. Please take note of the url though, that it must end with a backslash &#8216;/&#8217;.</p>
<p>And if browser returns with an error message below.</p>
<pre name="code" class="html">
XML Parsing Error: XML or text declaration not at start of entity
</pre>
<p>Please make sure there isn&#8217;t any trailing spaces before the <em>&lt;?php</em> and after <em>?&gt;</em> in your php file.</p>
<p>Next, we shall look at the code to create your Soap server.</p>
<pre name="code" class="php">
/**
 * Serve as the web service
 */
public function indexAction()
{
  $server = new Zend_Soap_Server( APP_URL . '/index/wsdl/' );
  $server-&gt;setClass( 'Models_Writer' );
  $server-&gt;handle();
  exit;
}
</pre>
<p>The above code instantiates <em>Zend_Soap_Server</em> with the url to the generated <em>WSDL</em> and set the class as <em>Models_Writer</em> and finally quits upon handling the request. Ok, now the <em>indexAction</em> is ready to serve as a Soap server.</p>
<p>Finally, to make sure that the server is handling the request correctly, let&#8217;s create the Soap client that makes a Soap request to the server.</p>
<pre name="code" class="php">
/**
 * Client to request from web service
 */
public function clientAction()
{
  $client = new Zend_Soap_Client( APP_URL . '/index/wsdl/' );
  $response = $client-&gt;write( 'hello world' );
  var_dump( $response );
  exit;
}
</pre>
<p>The above code first instantiates <em>Zend_Soap_Client</em> with the specified url to the <em>WSDL</em>. Line below then calls the function <em>write</em> from the server. Here, you were probably wondering where in the code have we specified the server url. Well, if you recall the previous code when we first created the <em>WSDL</em>, we has actually specified the Soap server url. As a result, Soap client is able to know the server url from the <em>WSDL</em>.</p>
<p>Now try access http://localhost/index/client/, the page should return you with the following line:</p>
<pre name="code" class="html">
string(11) "hello world"
</pre>
<p>Phew! it&#8217;s along explanation for a simple task. My arms are getting cramped now. I hope you are following well with my explanation. If not, well, I have a sample file you can <a href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-soap.zip">download</a> and test it on your local. I hope it works well. If not, let me know of your encounter.</p>
<p>Well, while experimenting this I have a stumbling block which I managed to find a solution to it. Here goes the encounter.</p>
<p>If you encounter the following error message:</p>
<pre name="code" class="html">
Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:wampbinphpphp5.2.8
includesZendSoapWsdl.php on line 94
Fatal error: Call to undefined method domdocument::loadXML() in C:wampbinphpphp5.2.8
includesZendSoapWsdl.php on line 95
</pre>
<p>You need disable <em>php_domxml</em> on your WampServer.</p>
<p>I hope I give enough information. Feel free to give your feedback. If you find this post useful, please help leave your rating below. Thanks! Happy coding! <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Source:</p>
<ul>
<li><a target="_blank" href="http://electrotek.wordpress.com/2008/04/19/soap-web-service-with-zend-framework/">SOAP web service with Zend Framework</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript call ActionScript</title>
		<link>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-call-actionscript</link>
		<comments>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 16:21:19 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=42</guid>
		<description><![CDATA[Just to share my finding on how to let javascript communicate with actionscript and vice versa. The complete source can be downloaded from <a title="source files" href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-external-as3.zip">here</a>. However I will highlight some important lines.]]></description>
			<content:encoded><![CDATA[<p>Just to share my finding on how to let javascript communicate with actionscript and vice versa. The complete source can be downloaded from <a title="source files" href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-external-as3.zip">here</a>. However I will highlight some important lines.</p>
<pre name="code" class="html:firstline[5]">
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
</pre>
<p>Make sure the above lines are inserted within your <code>&lt;head&gt;</code> tags. The script file <code>AC_RunActiveContent.js</code> may be changed depending on where you store the file. The path can be absolute path/url or relative path to your web root folder.</p>
<pre name="code" class="html:firstline[29]">
	var flash_ID = "External_AS3";
</pre>
<p>Next the value of <code>flash_ID</code> must match with your flash ID as defined in line 82. In this example, &#8220;External_AS3&#8243; is defined as the flash ID.</p>
<pre name="code" class="html:firstline[82]">
			'id', 'External_AS3',
</pre>
<p>Well, that&#8217;s all you need to do. Finally, verify using your browser. This sample has been tested working on Firefox, IE7, and Safari.</p>
<p>I hope this post helpful and feel free to feedback for any unsual encounter. Btw, all credits for this script goes to the following <a title="Flash and JavaScript communication" href="http://www.taterboy.com/blog/2008/08/flash-and-javascript-communication/" target="_blank">site</a>. <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

