<?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>Engwar &#187; perl</title>
	<atom:link href="http://engwar.com/tags/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://engwar.com</link>
	<description>Chintana Wilamuna&#039;s weblog</description>
	<lastBuildDate>Sat, 03 Jul 2010 08:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>StockTrader client using Catalyst</title>
		<link>http://engwar.com/post/93</link>
		<comments>http://engwar.com/post/93#comments</comments>
		<pubDate>Thu, 05 Mar 2009 17:46:35 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[catalyst]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[stocktrader]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=93</guid>
		<description><![CDATA[I&#8217;ve been rewriting the Perl StockTrader client using Catalyst for the past week or so. The first version of the client was done using (gasp!) Perl/CGI. So it was about time to do it right. Thanks to the excellent documentation Catalyst provide, it was a straightforward task. The main annoyance I faced was the lack [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been rewriting the Perl StockTrader client using <a href="http://www.catalystframework.org/">Catalyst</a> for the past week or so. The first version of the client was done using (gasp!) Perl/<a href="http://search.cpan.org/dist/CGI.pm/CGI.pm">CGI</a>. So it was about time to do it right. Thanks to the excellent documentation Catalyst provide, it was a straightforward task.</p>
<p>The main annoyance I faced was the lack of a proper error reporting mechanism. When you have an error on your controller, the script that starts the server simply refuse to start you can see the following VERY helpful error message in the console.</p>
<p><code>Unknown error<br />
Compilation failed in require at /usr/share/perl5/Catalyst/Utils.pm line 270.<br />
Compilation failed in require at ./script/stocktrader_server.pl line 55.</code></p>
<p>You cannot find out where the error occured. Only conclusion that you can make out of this is that there is an error in one of your controllers. Errors in models are shown correctly as they should. Template errors can easily be fixed. If you haven&#8217;t been doing incremental development, meaning you add a little bit of code then start the server and see whether everything has worked ok up to now, you&#8217;ll be in serious trouble. If you have the habit of writing large amounts of code without testing and keep testing for the last minute, Catalyst will torture you and put you through hellish debugging sessions for hours. I spent an inordinate amount of time trying to figure out the error and finally spotted that I&#8217;ve forgotten to make a single variable lexically scoped with my.</p>
<p>I also configured Log4perl to log all the errors to a log file and enabled the option to log warnings. Sadly I could not see any more log messages than I see in the console.</p>
<p>That aside, Catalyst is a fantastic framework to write web applications if you know Perl. As a big fan of frameworks it&#8217;s so exciting to see high quality open source MVC frameworks being developed that drastically reduce the effort of building web applications. Whatever the language you&#8217;re comfortable in programming, you can easily find a decent MVC framework for it these days. Well .. almost.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/93/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Catalyst</title>
		<link>http://engwar.com/post/85</link>
		<comments>http://engwar.com/post/85#comments</comments>
		<pubDate>Thu, 26 Feb 2009 03:18:05 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[catalyst]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=85</guid>
		<description><![CDATA[Last time I looked at Catalyst for a project, the time was really tight and had to do it by other means. This time however, I had slightly more time available so I started from Catalyst::Manual::Tutorial and boy, the docs are amazingly well written. Kennedy Clark has done a wonderful job with the documentation. Catalyst [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I looked at <a href="http://www.catalystframework.org/">Catalyst</a> for a project, the time was really tight and had to do it by other means. This time however, I had slightly more time available so I started from <a href="http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Tutorial.pod">Catalyst::Manual::Tutorial</a> and boy, the docs are amazingly well written. Kennedy Clark has done a wonderful job with the documentation.</p>
<p>Catalyst is a MVC framework written in Perl. If you&#8217;ve written any applications with Ruby on Rails or Django, the first thing you&#8217;ll notice is, like anything written in Perl, speed. Also, another difference that I see with Catalyst is the unprecedented flexibility it gives to the hands of the application developer. For a framework providing this level of flexibility, Catalyst is surprisingly easy to program with. Will write more about my Catalyst chronicles in another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/85/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl embedding example</title>
		<link>http://engwar.com/post/42</link>
		<comments>http://engwar.com/post/42#comments</comments>
		<pubDate>Wed, 09 Jul 2008 18:26:02 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[embedding]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=42</guid>
		<description><![CDATA[Since there was no progress from my last experiment, writing a rudimentary program without any WSF/C code seemed like a logical next step. For those of you who don&#8217;t know what I tried to do, here&#8217;s a brief explanation. I want to let other people provide Web services in Perl. My objective is to enable [...]]]></description>
			<content:encoded><![CDATA[<p>Since there was no progress from my <a href="http://engwar.com/post/40">last experiment</a>, writing a rudimentary program without any WSF/C code seemed like a logical next step.  For those of you who don&#8217;t know what I tried to do, here&#8217;s a brief explanation.  I want to let other people provide Web services in Perl.  My objective is to enable people to just copy their Perl scripts to, say, a folder and it&#8217;ll automatically become a Web service.  Let me explain that with an example.  Say you have the following Perl script,</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> getRandomNumber <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">return</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;m going to assuming you have configured your web server to execute Perl scripts ending with .pl via ModPerl for a directory called perl.  You copy the file and it&#8217;s accessible from http://localhost/perl/random.pl.  And it&#8217;s a web service now.  So you can send an XML payload like,</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;getRandomNumber</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>And get back something like,</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Since I&#8217;m using <a href="http://wso2.org/projects/wsf/c">WSF/C</a> as the underlying Web service engine and it provides various other facilities like WS-Security, WS-ReliableMessaging etc&#8230; at blazing speed, I wanna use it.</p>
<p>Here&#8217;s a simplified graphical version of the story,</p>
<p><img src="http://engwar.com/wp-content/uploads/2008/07/wsf-perl-service-arch.png" alt="" title="WSF/Perl service architecture" width="570" height="406" class="aligncenter size-full wp-image-43" /></p>
<p>1. Request comes to rand.pl via ModPerl and it gets executed.<br />
2. rand.pl then calls some methods in Service.pm module which in turn calls to some C functions.<br />
3. From one of those C functions we need to call a Perl function residing in the script the request came into.</p>
<p>If you&#8217;re wondering how the graphic relates to the story of copying your Perl script and making it a service (&#8216;cos there&#8217;s a Service.pm in the picture), please note that I&#8217;ve not yet figured out every detail in the system <img src='http://engwar.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Perl is segfaulting at all the bizzare places when this is executed. When things get this bad it&#8217;s time to write a very simple application that does the same thing without any WSF/C code.  Here&#8217;s how I did it.</p>
<p>I started by creating a new Perl extension in C.</p>
<pre>
$ h2xs -A -n ICanHaz
</pre>
<p>This&#8217;ll create the skeleton and all I have to do is edit the .xs file and put my code there.  Here&#8217;s my ICanHaz.xs file,</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;EXTERN.h&quot;</span>
<span style="color: #339933;">#include &quot;perl.h&quot;</span>
<span style="color: #339933;">#include &quot;XSUB.h&quot;</span>
<span style="color: #339933;">#include &lt;string.h&gt;</span>
&nbsp;
<span style="color: #339933;">#include &quot;ppport.h&quot;</span>
&nbsp;
<span style="color: #993333;">static</span>	PerlInterpreter <span style="color: #339933;">*</span>my_perl<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> cheeseburger<span style="color: #009900;">&#40;</span> <span style="color: #993333;">void</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>embedding<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;/usr/local/apache2/perl/exec-this.pl&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    my_perl <span style="color: #339933;">=</span> perl_alloc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_construct<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PL_exit_flags <span style="color: #339933;">|=</span> PERL_EXIT_DESTRUCT_END<span style="color: #339933;">;</span>
    perl_parse<span style="color: #009900;">&#40;</span>my_perl<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> embedding<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_run<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_destruct<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_free<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PERL_SYS_TERM<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
MODULE <span style="color: #339933;">=</span> ICanHaz		PACKAGE <span style="color: #339933;">=</span> ICanHaz		
&nbsp;
<span style="color: #993333;">void</span>
cheeseburger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Now you have to edit Makefile.PL and give the output of, <code>perl -MExtUtils::Embed -e ccopts -e ldopts</code> to the compiler flags.  After that you can compile and install the module.  Here&#8217;s what&#8217;s inside exec-this.pl,</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">sub</span> keele_teh_urth <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;oh noez. i iz gud kitteh&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just a simple function.  Then I wrote another Perl script to invoke the method in my C extension.  Here&#8217;s the program,</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/local/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> ICanHaz<span style="color: #339933;">;</span>
&nbsp;
ICanHaz<span style="color: #339933;">::</span><span style="color: #006600;">cheeseburger</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Content-type: text/html<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;dis segfaults, srsly.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Executing this file via ModPerl results in a segmentation fault.  As you can see even the simplest case of embedding will not execute through ModPerl.  Switched to CGI and got the same results.  Possible alternatives to try is 1) move all the embedding stuff to it&#8217;s own executable, when you need to call the Perl function from C do a fork followed by exec, pass the payload as a parameter, store the result in a shared memory and once done read from it (this .. um .. a bit ugly to say the least).  Second alternative is to use <a href="http://search.cpan.org/~adamk/PPI-1.203/lib/PPI.pm">PPI</a>.  I haven&#8217;t looked into PPI yet so don&#8217;t know for sure whether it&#8217;s possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/42/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Perl embedding woes</title>
		<link>http://engwar.com/post/40</link>
		<comments>http://engwar.com/post/40#comments</comments>
		<pubDate>Thu, 03 Jul 2008 14:33:55 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[mod_perl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/c]]></category>
		<category><![CDATA[wsf/perl]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=40</guid>
		<description><![CDATA[While developing server side components that enables providing Web services using Perl bumped into a brick wall. First the requirement is when a client request comes, need to extract the payload and pass it to WSF/C which acts as the underlying Web services engine. So WSF/C knows how to process the incoming XML payload and [...]]]></description>
			<content:encoded><![CDATA[<p>While developing server side components that enables providing Web services using Perl bumped into a brick wall.  First the requirement is when a client request comes, need to extract the payload and pass it to WSF/C which acts as the underlying Web services engine.  So WSF/C knows how to process the incoming XML payload and do what it does and return another XML payload which is then passed back to the client who send the request.  And the business logic is written using Perl.  Simple, I know.</p>
<p>We used SWIG to generate some wrapper functions (plus some custom written C code) which belongs to WSF/C and wrote a Perl module encapsulating the lower level stuff.  So when you have to write a Web service in Perl all you have to do is <code>use WSO2::WSF::Service;</code> in your script and call a couple of functions.  As the deployment scenario we choose Apache with ModPerl.  That combination seemd logical and some of the heavy trafficked sites are using that.</p>
<p>It gets interesting when you test the whole thing.  Apache is configured to run ModPerl on a folder named <code>/perl</code> so requests matching <code>/perl/something</code> will go through ModPerl.  <code>ResponseHandler</code> is <code>ModPerl::Registry</code> and also <code>GlobalRequest</code> has been enabled to get the global request via <code>Apache::RequestUtil->request()</code>.</p>
<p>Say, we have a service script named <code>echo_service.pl</code> which simply return back whatever it gets.  Here&#8217;s the code,</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> WSO2<span style="color: #339933;">::</span><span style="color: #006600;">WSF</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> WSO2<span style="color: #339933;">::</span><span style="color: #006600;">WSF</span><span style="color: #339933;">::</span><span style="color: #006600;">WSService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Apache2<span style="color: #339933;">::</span><span style="color: #006600;">RequestUtil</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$payload</span> <span style="color: #339933;">=</span><span style="color: #cc0000; font-style: italic;">&lt;&lt;E;
&lt;ns1:echoString xmlns:ns1=&quot;http://perl.axis2.org/samples&quot;&gt;
  &lt;text&gt;plurk u can haz&lt;/text&gt;
&lt;/ns1:echoString&gt;
E</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> echoFunction <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$arg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$message</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #006600;">WSF</span><span style="color: #339933;">::</span><span style="color: #006600;">WSMessage</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'payload'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$arg</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">return</span> <span style="color: #0000ff;">$message</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%operations</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">'echoString'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'echoFunction'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span>MOD_PERL<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$r</span> <span style="color: #339933;">=</span> Apache2<span style="color: #339933;">::</span><span style="color: #006600;">RequestUtil</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">request</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$service</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #006600;">WSF</span><span style="color: #339933;">::</span><span style="color: #006600;">WSService</span><span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'operations'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">\%operations</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'action'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'testAction'</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #0000ff;">$service</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">reply</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$r</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When it goes to the reply method it&#8217;ll call up some C routines.  Inside one of those C functions, after determining the function name to call by looking at the request payload, we need to call it.  From a C function.  How can you do that?  By embedding the Perl interpreter.  AFAIK, you cannot call a Perl function from C without embedding the interpreter (please correct me if I&#8217;m wrong).  In WSF/Ruby server side there was no such issue because the entire Ruby module (<code>WSService</code> class and methods) is written in C.</p>
<p>Let me show you the code that embeds the interpreter and calls the function after looking at the XML payload in the request,</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> axiom_node_t <span style="color: #339933;">*</span>
wsf_xml_msg_recv_invoke_other<span style="color: #009900;">&#40;</span>axis2_msg_recv_t<span style="color: #339933;">*</span> msg_recv<span style="color: #339933;">,</span>
        <span style="color: #993333;">const</span> axutil_env_t<span style="color: #339933;">*</span> env<span style="color: #339933;">,</span>
        wsf_svc_info_t<span style="color: #339933;">*</span> svc_info<span style="color: #339933;">,</span>
        axis2_msg_ctx_t<span style="color: #339933;">*</span> in_msg_ctx<span style="color: #339933;">,</span>
        axis2_msg_ctx_t<span style="color: #339933;">*</span> out_msg_ctx<span style="color: #339933;">,</span>
        axis2_char_t<span style="color: #339933;">*</span> function_name<span style="color: #339933;">,</span>
        axis2_char_t<span style="color: #339933;">*</span> class_name<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    AXIS2_PARAM_CHECK<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>error<span style="color: #339933;">,</span> svc_info<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    AXIS2_PARAM_CHECK<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>error<span style="color: #339933;">,</span> in_msg_ctx<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    AXIS2_PARAM_CHECK<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>error<span style="color: #339933;">,</span> out_msg_ctx<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    axiom_node_t <span style="color: #339933;">*</span>node <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axiom_node_t <span style="color: #339933;">*</span>om_node <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axiom_soap_envelope_t <span style="color: #339933;">*</span>envelope <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axiom_soap_body_t <span style="color: #339933;">*</span>body <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axis2_char_t <span style="color: #339933;">*</span>retstr <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axiom_node_t <span style="color: #339933;">*</span>soap_body_node <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* extracting payload from the soap message */</span>
    envelope <span style="color: #339933;">=</span> axis2_msg_ctx_get_soap_envelope<span style="color: #009900;">&#40;</span>in_msg_ctx<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>envelope<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;[wsf-perl-service] soap envelope not found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    body <span style="color: #339933;">=</span> axiom_soap_envelope_get_body<span style="color: #009900;">&#40;</span>envelope<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>body<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;[wsf-perl-service] soap body not found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    soap_body_node <span style="color: #339933;">=</span> axiom_soap_body_get_base_node<span style="color: #009900;">&#40;</span>body<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>soap_body_node<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;[wsf-perl-service] soap body base node not found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    om_node <span style="color: #339933;">=</span> axiom_node_get_first_child<span style="color: #009900;">&#40;</span>soap_body_node<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>om_node<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    axis2_char_t <span style="color: #339933;">*</span>embedding<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;-M'WSO2::WSF::C; WSO2::WSF::Service;'&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>svc_info<span style="color: #339933;">-&gt;</span>script_filename<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span>
                <span style="color: #ff0000;">&quot;perl function invocation failed, script_file name not found for &quot;</span>
                <span style="color: #ff0000;">&quot;service %s&quot;</span><span style="color: #339933;">,</span> svc_info<span style="color: #339933;">-&gt;</span>svc_name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #808080; font-style: italic;">/* passing script real path into perl interpreter. */</span>
    embedding<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> svc_info<span style="color: #339933;">-&gt;</span>script_filename<span style="color: #339933;">;</span>
&nbsp;
    my_perl <span style="color: #339933;">=</span> perl_alloc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PL_perl_destruct_level <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/*    PL_use_safe_putenv = 1; */</span>
    PERL_SET_CONTEXT<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_construct<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    PL_origalen <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    PERL_SET_CONTEXT<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>perl_parse<span style="color: #009900;">&#40;</span>my_perl<span style="color: #339933;">,</span> xs_init<span style="color: #339933;">,</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> embedding<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;perl_parse method failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    PL_exit_flags <span style="color: #339933;">|=</span> PERL_EXIT_DESTRUCT_END<span style="color: #339933;">;</span>
    <span style="color: #808080; font-style: italic;">/* perl_run(my_perl); */</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>SvTRUE<span style="color: #009900;">&#40;</span>ERRSV<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_DEBUG<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;invoke perl function failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    retstr <span style="color: #339933;">=</span> invoke_perl_function<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> om_node<span style="color: #339933;">,</span> function_name<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>retstr<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        node <span style="color: #339933;">=</span> wsf_util_deserialize_buffer<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> retstr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    PERL_SET_CONTEXT<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_destruct<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PERL_SET_CONTEXT<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    perl_free<span style="color: #009900;">&#40;</span>my_perl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PERL_SYS_TERM<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    AXIS2_LOG_DEBUG<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> axiom_node_to_string<span style="color: #009900;">&#40;</span>node<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> node<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> axis2_char_t <span style="color: #339933;">*</span>
invoke_perl_function<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> axutil_env_t <span style="color: #339933;">*</span>env<span style="color: #339933;">,</span> axiom_node_t <span style="color: #339933;">*</span>om_node<span style="color: #339933;">,</span>
        axis2_char_t <span style="color: #339933;">*</span>operation<span style="color: #339933;">,</span> axis2_char_t <span style="color: #339933;">*</span>class_name<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> count <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    axis2_char_t <span style="color: #339933;">*</span>inmsg <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    SV <span style="color: #339933;">**</span>wsmsg_str <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* hold the value for the key 'payload' in WSMessage */</span>
    SV <span style="color: #339933;">*</span>wsmsg_ref <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* reference to a WSMessage object */</span>
    HV <span style="color: #339933;">*</span>wsmsg <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* WSMessage object */</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>tmp_str <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    axis2_char_t <span style="color: #339933;">*</span>res_payload_str <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>operation<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        AXIS2_LOG_DEBUG<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span>
                <span style="color: #ff0000;">&quot;invoking perl function failed, operation not available&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>om_node<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        inmsg <span style="color: #339933;">=</span> axiom_node_to_string<span style="color: #009900;">&#40;</span>om_node<span style="color: #339933;">,</span> env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* declare and init a local copy of the Perl stack pointer */</span>
    dSP<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* mortal SVs for the stack */</span>
    ENTER<span style="color: #339933;">;</span>
    SAVETMPS<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* &quot;record&quot; the current stack pointer */</span>
    PUSHMARK<span style="color: #009900;">&#40;</span>SP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* push parameters to the stack */</span>
    XPUSHs<span style="color: #009900;">&#40;</span>sv_2mortal<span style="color: #009900;">&#40;</span>newSVpv<span style="color: #009900;">&#40;</span>inmsg<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* make the global copy of the stack pointer same as the local copy */</span>
    PUTBACK<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* call the Perl function, expecting a scalar to be returned */</span>
    count <span style="color: #339933;">=</span> call_pv<span style="color: #009900;">&#40;</span>operation<span style="color: #339933;">,</span> G_SCALAR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* refreshing the local copy of the stack pointer, call_pv might have reallocated it */</span>
    SPAGAIN<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">!=</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        croak<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;perl function invocation failed&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        AXIS2_LOG_ERROR<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>log<span style="color: #339933;">,</span> AXIS2_LOG_SI<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;perl function %s invocation failed&quot;</span><span style="color: #339933;">,</span> operation<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* get the scalar reference from the stack */</span>
    wsmsg_ref <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SV <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> POPs<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* getting the object from the reference */</span>
    wsmsg <span style="color: #339933;">=</span> SvRV<span style="color: #009900;">&#40;</span>wsmsg_ref<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* fetching the value of the member variable 'payload' from WSMessage */</span>
    wsmsg_str <span style="color: #339933;">=</span> hv_fetch<span style="color: #009900;">&#40;</span>wsmsg<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;payload&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">7</span><span style="color: #339933;">,</span> FALSE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* perl scalar to c string */</span>
    tmp_str <span style="color: #339933;">=</span> SvPVutf8_nolen<span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>wsmsg_str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    res_payload_str <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>axis2_char_t <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> savepvn<span style="color: #009900;">&#40;</span>tmp_str<span style="color: #339933;">,</span> strlen<span style="color: #009900;">&#40;</span>tmp_str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    PUTBACK<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* cleaning up mortal SVs */</span>
    FREETMPS<span style="color: #339933;">;</span>
    LEAVE<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> res_payload_str<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://wso2.org/repos/wso2/trunk/wsf/perl/service/wsf_xml_msg_recv.c">Full source is here</a> (note that the actual source might be different from what you see here since it&#8217;s being modified at the time of this writing).  Also <code>my_perl</code> is declared as a static variable.   The problem is when my_perl gets freed it looks like ModPerl is also affected.  A valgrind report shows that it tries to read from a pointer after <code>perl_free()</code> gets called.  As the following valgrind exerpt shows,</p>
<pre>
==16101== Invalid read of size 4
==16101==    at 0x62AD118: _wrap_wsf_worker_process_request (wsf_wrap.c:4167)
==16101==    by 0x5476D68: Perl_pp_entersub (pp_hot.c:2847)
==16101==    by 0x5438092: Perl_runops_debug (dump.c:1931)
==16101==    by 0x546FF97: Perl_call_sv (perl.c:2646)
==16101==    by 0x4DC2AF3: modperl_callback (modperl_callback.c:101)
==16101==    by 0x4DC388B: modperl_callback_run_handlers (modperl_callback.c:262)
==16101==    by 0x4DC4289: modperl_callback_per_dir (modperl_callback.c:369)
==16101==    by 0x4DBB53E: modperl_response_handler_run (mod_perl.c:1004)
==16101==    by 0x4DBB704: modperl_response_handler_cgi (mod_perl.c:1099)
==16101==    by 0x25A6C: ap_run_handler (config.c:158)
==16101==    by 0x295BE: ap_invoke_handler (config.c:372)
==16101==    by 0x35D80: ap_process_request (http_request.c:258)
==16101==  Address 0x649051c is 12 bytes inside a block of size 1,692 free'd
==16101==    at 0x480590A: free (vg_replace_malloc.c:323)
==16101==    by 0x546AED4: perl_free (perl.c:1394)
==16101==    by 0x62BD599: wsf_xml_msg_recv_invoke_business_logic_sync (wsf_xml_msg_recv.c:452)
==16101==    by 0x613D503: axis2_msg_recv_invoke_business_logic (msg_recv.c:392)
==16101==    by 0x613DB34: axis2_msg_recv_receive_impl (msg_recv.c:319)
==16101==    by 0x613D583: axis2_msg_recv_receive (msg_recv.c:431)
==16101==    by 0x61327D4: axis2_engine_receive (engine.c:315)
==16101==    by 0x6167177: axis2_http_transport_utils_process_http_post_request (http_transport_utils.c:595)
==16101==    by 0x62BE9B3: wsf_worker_process_request (wsf_worker.c:301)
==16101==    by 0x62AD0F7: _wrap_wsf_worker_process_request (wsf_wrap.c:4166)
==16101==    by 0x5476D68: Perl_pp_entersub (pp_hot.c:2847)
==16101==    by 0x5438092: Perl_runops_debug (dump.c:1931)
</pre>
<p>Still haven&#8217;t been able to pin down what exactly happens when <code>perl_free()</code> gets called <img src='http://engwar.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/40/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WSF/Perl 1.1</title>
		<link>http://engwar.com/post/39</link>
		<comments>http://engwar.com/post/39#comments</comments>
		<pubDate>Thu, 29 May 2008 04:15:13 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[wsf/perl]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=39</guid>
		<description><![CDATA[Just uploaded WSF/Perl 1.1 to CPAN. Doesn&#8217;t show up there yet but will be available within a few hours. This has many things added since the last release (which was ages ago). You could now do WS-ReliableMessaging, WS-Security, WS-SecurityPolicy. The release became ridiculously late due to couple of bugs which took me REALLY LONG to [...]]]></description>
			<content:encoded><![CDATA[<p>Just uploaded WSF/Perl 1.1 to CPAN.  Doesn&#8217;t show up there yet but will be available within a few hours.  This has many things added since the last release (which was ages ago).  You could now do WS-ReliableMessaging, WS-Security, WS-SecurityPolicy.  The release became ridiculously late due to couple of bugs which took me REALLY LONG to debug and fix.  Ouch.  Download and give it a shot.  It&#8217;ll take couple of seconds to compile.  If you&#8217;re in a generous mood I recommend <a href="http://www.everytopicintheuniverseexceptchickens.com/">contributing to a good cause</a> in those few seconds.</p>
<p>This release again has only support only on the client side, if you&#8217;re looking forward to write/host services with WSF/Perl you still have to wait a bit more.  <a href="http://nethu.org/">Dinesh</a> and Danushka has done some excellent progress on that front and will be finishing it soon.  If you wanna know how it&#8217;s taking shape, then <a href="http://wso2.org/repos/wso2/trunk/wsf/perl/service/">by all means</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SWIG binary string caveat</title>
		<link>http://engwar.com/post/31</link>
		<comments>http://engwar.com/post/31#comments</comments>
		<pubDate>Thu, 24 Apr 2008 11:48:37 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[mtom]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[swig]]></category>
		<category><![CDATA[wsf/perl]]></category>

		<guid isPermaLink="false">http://engwar.com/post/31</guid>
		<description><![CDATA[If you have been working with Web services you might have heard the term MTOM. I was getting MTOM support to work on WSF/Perl and the image that was not getting saved properly. Only the first few bytes was written to the file. The magic numbers that were getting saved was enough for the file [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been working with Web services you might have heard the term <a href="http://en.wikipedia.org/wiki/MTOM">MTOM</a>.  I was getting MTOM support to work on <a href="http://wso2.org/projects/wsf/perl">WSF/Perl</a> and the image that was not getting saved properly.  Only the first few bytes was written to the file.  The magic numbers that were getting saved was enough for the file command to say it&#8217;s a JPEG image.  From the C layer it was reading image data to a character pointer and returning it to the scripting language.</p>
<p>The C function reading the image had a <code>char *</code> return type.  The code that was generated by SWIG was returning the pointer after running it through the following function,</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">SWIG_FromCharPtr<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>cptr<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> SWIG_FromCharPtrAndSize<span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>cptr <span style="color: #339933;">?</span> strlen<span style="color: #009900;">&#40;</span>cptr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The rough English translation of the above is, &#8220;you&#8217;re screwed&#8221;.  Why?  The <code>strlen</code> doesn&#8217;t particularly like to go through binary strings.  It&#8217;ll choke and die when it see a null byte.  So, only the content before the null byte was returned.</p>
<p>The solution was to create a string using the API provided by the particular scripting language.  For Perl it&#8217;s <code>newSVpv</code> and for Ruby it&#8217;s <code>rb_str_new</code>.  Wrapped the functions inside an ifdef (thanks to the nice SWIG&lt;lang&gt; defines) and all is set for MTOM!</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/31/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom SOAP headers using WSF/Perl</title>
		<link>http://engwar.com/post/30</link>
		<comments>http://engwar.com/post/30#comments</comments>
		<pubDate>Fri, 04 Apr 2008 13:05:00 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[wsf/perl]]></category>

		<guid isPermaLink="false">http://engwar.com/post/30</guid>
		<description><![CDATA[SOAP headers are used to convey additional control information that complements the information in the payload. For example WS-Security is one such thing that use SOAP headers to say how integrity and confidentiality should be achieved. Apart from the specs that define standard SOAP headers you could also define your own custom headers which could [...]]]></description>
			<content:encoded><![CDATA[<p>SOAP headers are used to convey additional control information that complements the information in the payload.  For example WS-Security is one such thing that use SOAP headers to say how integrity and confidentiality should be achieved.  Apart from the specs that define standard SOAP headers you could also define your own custom headers which could then be processed as you wish from your application.  Let&#8217;s see how we can generate custom SOAP headers using WSF/Perl.  You&#8217;ll need to get the SVN head revision of <a href="http://wso2.org/projects/wsf/perl">WSF/Perl</a> in order to get this working (as of this writing).</p>
<p>First, let&#8217;s see an example from &#8220;Processing XML with Java&#8221; (<a href="http://www.amazon.com/Processing-XML-Java-TM-Guide/dp/0201771861/">Amazon page</a>) also <a href="http://www.cafeconleche.org/books/xmljava">available online here</a>.  I&#8217;m using <a href="http://www.cafeconleche.org/books/xmljava/chapters/ch02s06.html#bid_with_credit_card.xml">the SOAP header example</a> to show you how to generate the exact thing.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Payment</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://namespaces.cafeconleche.org/xmljava/ch2/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Elliotte Harold<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Issuer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>VISA<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Issuer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5125456787651230<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Expires<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2005-12<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Expires<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Payment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Here&#8217;s how you can generate the above headers using WSF/Perl,</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">my <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Elliotte Harold'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$issuer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Issuer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'VISA'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Number'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'5125456787651230'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$expires</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Expires'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'2005-12'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$payment</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Payment'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'ns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://namespaces.cafeconleche.org/xmljava/ch2/'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$issuer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$number</span><span style="color: #339933;">,</span> <span style="color: #000088;">$expires</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSClient</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #339933;">...,</span>
     <span style="color: #0000ff;">'inputHeaders'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000088;">$payment</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the <a href="http://www.cafeconleche.org/books/xmljava/chapters/ch02s06.html#signed_bid_with_payment.xml">next example</a> it shows the header with the <code>mustUnderstand</code> attribute set, this is how you set it,</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">my <span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSClient</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #339933;">...,</span>
     <span style="color: #0000ff;">'mustUnderstand'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'true'</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'inputHeaders'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000088;">$payment</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Next, I&#8217;ll take an example from a <a href="http://www.ibm.com/developerworks/webservices/library/ws-soapheaders/index.html?ca=drs">developerWorks article that shows you how to manipulate SOAP headers in WebSphere</a>.  Consider the following header contents (Listing 4 in the article)</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MyPrefix:CallingApplication</span> <span style="color: #000066;">xmlns:MyPrefix</span>=<span style="color: #ff0000;">&quot;http://SOAPHeaderDemonstration&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ServiceRequester1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;timeRequestMade<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>13:20:00<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/timeRequestMade<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/MyPrefix:CallingApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The main difference in this is that it contains a custom prefix for the element <code>CallingApplication</code>.  Here&#8217;s the WSF/Perl code to generate this header,</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">my <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ServiceRequester1'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$version</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'version'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1.0'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$timereq</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'timeRequestMade'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'13:20:00'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$capp</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSHeader</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'CallingApplication'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ns'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://SOAPHeaderDemonstration'</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'nsprefix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'MyPrefix'</span><span style="color: #339933;">,</span>
     <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timereq</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my <span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WSO2<span style="color: #339933;">::</span><span style="color: #004000;">WSF</span><span style="color: #339933;">::</span><span style="color: #004000;">WSClient</span><span style="color: #009900;">&#40;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #339933;">...,</span>
     <span style="color: #0000ff;">'inputHeaders'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000088;">$capp</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you saw in the examples, <code>WSHeader</code> class facilitate creating custom SOAP headers with WSF/Perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/30/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scripting language bindings</title>
		<link>http://engwar.com/post/20</link>
		<comments>http://engwar.com/post/20#comments</comments>
		<pubDate>Thu, 03 Jan 2008 21:23:08 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[swig]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://engwar.com/post/20</guid>
		<description><![CDATA[Besides having the ability to provide a high level and a more developer friendly API, making a scripting language binding to an existing C library could make the testing of the library a less painful process. Initially I was under the impression that exposing low level C functions to the scripting language will make it [...]]]></description>
			<content:encoded><![CDATA[<p>Besides having the ability to provide a high level and a more developer friendly API, making a scripting language binding to an existing C library could make the testing of the library a less painful process.  Initially I was under the impression that exposing low level C functions to the scripting language will make it flexible so that you could build a high level module in that scripting language encapsulating those low level functions.  True.  But the big downside when you have, say, 3 different language bindings for your C library all exposing low level functions is, a) you need to spend a lot of time writing the module in the respective scripting language b) too much overhead when it comes to debugging.  If you find a subtle bug which you have overlooked in the Ruby binding, now you need to change the same thing on your Python and Perl bindings as well.</p>
<p>This was a real issue that we came across developing the Ruby and Perl bindings for the <a href="http://wso2.org/projects/wsf/c">WSF/C</a> framework.  Also having the Python binding in sight.  We use <a href="http://www.swig.org/">SWIG</a> to generate language bindings.  Having learned the price you have to pay exposing the lowest level functions, I&#8217;m gonna look into refactoring the existing code limiting the stuff that&#8217;s exposed to the scripting language to a minimum.  So, code that goes into the module which need to be written in the respective scripting language is very small.</p>
<p>At the end of the day it&#8217;s about making you feel sooo comfortable when you program in your favourite scripting language, exposing your services with the doublew ess death star goodness with a few lines which will call the C library for maximum performance which will then give the result back to your favourite scripting language scripting language.  It&#8217;s a deadly game out there <img src='http://engwar.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Yes, you can breathe now.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/20/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WSF/Perl is out there</title>
		<link>http://engwar.com/post/11</link>
		<comments>http://engwar.com/post/11#comments</comments>
		<pubDate>Mon, 22 Oct 2007 14:54:40 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://engwar.com/post/11</guid>
		<description><![CDATA[Initial version of WSF/Perl was released a few weeks ago and I&#8217;ve been too lazy to write a blog post about it. You can install it via CPAN. Documentation is available in the familiar POD format. You can find more info from WSF/Perl project page.]]></description>
			<content:encoded><![CDATA[<p>Initial version of WSF/Perl was released a few weeks ago and I&#8217;ve been too lazy to write a blog post about it.  You can install it via CPAN.  Documentation is available in the familiar <a href="http://search.cpan.org/~chintana/WSO2-WSF-Perl-v1.0.0/WSO2-WSF/lib/WSO2/WSF.pm">POD format</a>.  You can find more info from <a href="http://wso2.org/projects/wsf/perl">WSF/Perl project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webservices with Perl</title>
		<link>http://engwar.com/post/10</link>
		<comments>http://engwar.com/post/10#comments</comments>
		<pubDate>Tue, 18 Sep 2007 15:19:22 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://engwar.com/post/10</guid>
		<description><![CDATA[If you have been doing Web services with SOAP::Lite you&#8217;ll be thrilled to hear that there is another library that&#8217;ll provide WS-* goodness to consume and provide services. Well at least on the way of providing Still there is no support for all the WS- specs implemented by WSF/C but it&#8217;s on the pipeline. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been doing Web services with SOAP::Lite you&#8217;ll be thrilled to hear that there is another library that&#8217;ll provide WS-* goodness to consume and provide services.  Well at least on the way of providing <img src='http://engwar.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Still there is no support for all the WS- specs implemented by WSF/C but it&#8217;s on the pipeline.  I&#8217;ve been doing development of the Perl binding to the <a href="http://wso2.com/">WSO2</a> <a href="http://wso2.org/projects/wsf/c">WSF/C</a> library.  It&#8217;s not officially released yet but if you&#8217;re feeling a bit adventurous you can try playing with the <a href="http://wso2.org/repos/wso2/trunk/wsf/perl/">svn</a>.  Still the installation is a bit dodgy.  Haven&#8217;t made it a CPAN module yet but it&#8217;ll be when it&#8217;s released.  Still there are loads of improvements to be done.  I have to get rid of those quick and dirty wrapper functions and use typemaps.  Also need to get a proper exception mechanism in place.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/10/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
