<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>log.squish.net</title>
	<link>http://log.squish.net</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 08 Nov 2008 11:20:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Mserv client for iPhone</title>
		<link>http://log.squish.net/2008/11/08/mserv-client-for-iphone/</link>
		<comments>http://log.squish.net/2008/11/08/mserv-client-for-iphone/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 11:20:32 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<category><![CDATA[ramblings]]></category>

		<guid isPermaLink="false">http://log.squish.net/2008/11/08/mserv-client-for-iphone/</guid>
		<description><![CDATA[Cor, Andrew Bednarz has written an iPhone client for mserv.  Thanks Andrew!

If only I had an iPhone  
]]></description>
			<content:encoded><![CDATA[<p>Cor, Andrew Bednarz has written an <a href="http://abednarz.net/wp/?cat=19">iPhone</a> client for <a href="http://www.mserv.org/">mserv</a>.  Thanks Andrew!</p>
<p><img src="http://www.abednarz.net/iphone/mservClientIP1.png" alt="mserv controller for iPhone" width="160" /></p>
<p>If only I had an iPhone <img src='http://log.squish.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/11/08/mserv-client-for-iphone/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Talking to Sharepoint Lists with Perl</title>
		<link>http://log.squish.net/2008/10/11/perl-sharepoint/</link>
		<comments>http://log.squish.net/2008/10/11/perl-sharepoint/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 17:19:52 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<category><![CDATA[ramblings]]></category>

		<guid isPermaLink="false">http://log.squish.net/2008/10/11/perl-sharepoint/</guid>
		<description><![CDATA[I&#8217;ve recently done some work to talk to Sharepoint with Perl and thought I would share my experiences.  I couldn&#8217;t find any example code out there in the wild for doing this, so I had to figure a lot of this out by trial and error.  It&#8217;s actually quite simple once you&#8217;ve got [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently done some work to talk to Sharepoint with Perl and thought I would share my experiences.  I couldn&#8217;t find any example code out there in the wild for doing this, so I had to figure a lot of this out by trial and error.  It&#8217;s actually quite simple once you&#8217;ve got it set up.  I hope this helps someone.</p>
<p>This code shows you how to connect via the Web Services interface with NTLM authentication (i.e. standard Windows authentication) to manipulate Lists, but you could do almost anything.</p>
<p>You will need:</p>
<ul>
<li><strong>SOAP::Lite</strong> for talking to Sharepoint Web Services interface</li>
<li><strong>LWP::Authen::Ntlm</strong> to enable LWP to talk NTLM</li>
<li><strong>Authen::NTLM</strong> which LWP::Authen::Ntlm uses for the NTLM authentication</li>
</ul>
<p>Some information sources that you&#8217;ll find useful:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/cc752745.aspx">MSDN Sharepoint Web Services</a> documentation
	</li>
<li>Go to /_vti_bin/lists.asmx on your Sharepoint server for a lot of useful information
	</li>
<li>Go to /_vti_bin/lists.asmx?WSDL for the WSDL definitions (if all else fails)
</li>
</ul>
<p>So here&#8217;s how to get started:</p>
<pre>use LWP::UserAgent;
use LWP::Debug;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };
import SOAP::Data 'name', 'value';
our $sp_endpoint = 'http://sp.example.com/sites/mysite/_vti_bin/lists.asmx';
our $sp_domain = 'sp.example.com:80';
our $sp_username = 'DOMAIN\username';
our $sp_password = 'xyz';
</pre>
<p>The SOAP::Lite module needs to be told how to construct the SOAPAction header properly for Sharepoint.  The on_action does just this, and means you&#8217;ll end up with a SOAPAction appending the URL and the method name together without anything in between (stops the default # that Sharepoint doesn&#8217;t want).</p>
<pre>if ($debug) {
    LWP::Debug::level('+');
    SOAP::Lite->import(+trace => 'all');
}
</pre>
<p>Use the above code to turn on debugging if you get errors.</p>
<pre>my @ua_args = (keep_alive => 1);
my @credentials = ($sp_domain, "", $sp_endpoint, $sp_password);
my $schema_ua = LWP::UserAgent->new(@ua_args);
$schema_ua->credentials(@credentials);
$soap = SOAP::Lite->proxy($sp_endpoint, @ua_args, credentials => \@credentials);
$soap->schema->useragent($schema_ua);
$soap->uri("http://schemas.microsoft.com/sharepoint/soap/");
</pre>
<p>This complete mess is the necessary steps to get SOAP::Lite to use a properly configured LWP UserAgent to do NTLM authentication.  SOAP::Lite uses two UserAgents, one for the main SOAP calls and one for the Schema fetching.  Although you don&#8217;t need to fetch a schema, I&#8217;ve included the proper set up above in case you want to call <em>$soap->service(&#8221;$sp_endpoint?WSDL&#8221;);</em> for some reason.</p>
<pre>$lists = $soap->GetListCollection();
quit(1, $lists->faultstring()) if defined $lists->fault();
</pre>
<p>That&#8217;s all you need to do to get a list of all the lists on your Sharepoint site.  And we can print them out:</p>
<pre>my @result = $lists->dataof('//GetListCollectionResult/Lists/List');
foreach my $data (@result) {
    my $attr = $data->attr;
    foreach my $a qw/Title Description DefaultViewUrl Name ID WebId ItemCount/ {
        printf "%-16s %s\n", $a, $attr->{$a};
    }
    print "\n";
}
</pre>
<p>Or if you need to find a particular list to do operations on it, search for it in the results by looking up the Title with something like this:</p>
<pre>sub lists_getid
{
    my $title = shift;
    my @result = $lists->dataof('//GetListCollectionResult/Lists/List');
    foreach my $data (@result) {
        my $attr = $data->attr;
        return $attr->{ID} if ($attr->{Title} eq $title);
    }
    return undef;
}
</pre>
<p>And here&#8217;s another useful subroutine to get all the items in a list:</p>
<pre>sub lists_getitems
{
    my $listid = shift;
    my $in_listName = name('listName' => $listid);
    my $in_viewName = name('viewName' => '');
    my $in_rowLimit = name('rowLimit' => 99999);
    my $call = $soap->GetListItems($in_listName, $in_viewName, $in_rowLimit);
    quit(1, $call->faultstring()) if defined $call->fault();
    return $call->dataof('//GetListItemsResult/listitems/data/row');
}
</pre>
<p>That will use the default view.  The 99999 is a hack to get all the items and stop the server &#8220;paging&#8221; the results.  Putting this together you&#8217;d do something like this:</p>
<pre>my $list_id = lists_getid('MyList');
print "List ID is: $list_id\n";
my @items = lists_getitems($list_id);
foreach my $data (@items) {
    my $attr = $data->attr;
    # print Dumper($attr);
}
</pre>
<p>Here&#8217;s some code to add a new list item:</p>
<pre>my $field_id = name('Field', 'New')->attr({ Name => 'ID'});
my $field_linktitle = name('Field', $title)->attr({ Name => 'Title'});
my $field_something = name('Field', $something_else)->attr({ Name => 'Something_x0020_Else'});
my $method = name('Method', [$field_id, $field_linktitle, $field_something])->attr({ ID => "anything", Cmd => 'New'});
my $batch = name('Batch', \$method);
my $in_listName = name('listName' => $list_id);
my $in_updates = name('updates' => \$batch);
my $call = $soap->UpdateListItems($in_listName, $in_updates);
quit(1, $call->faultstring()) if defined $call->fault();
</pre>
<p>The content for Name=&#8221;ID&#8221; must be &#8220;New&#8221;.  Where it says &#8220;anything&#8221; it really can be anything, it&#8217;s just an identifier for responses.  You can also see that spaces are encoded as _x0020_.</p>
<pre>my $field_id = name('Field', $sp_id)->attr({ Name => 'ID'});
my $field_something = name('Field', $something_else)->attr({ Name => 'Something_x0020_Else'});
my $method = name('Method', [$field_id, $field_appname])->attr({ ID => $jira_name, Cmd => 'Update'});
</pre>
<p>The above is for modifying an item.  In this case the $sp_id must be set appropriately from the &#8220;id&#8221; attribute of a list item you previously fetched.</p>
<p>I hope that helps someone.  Perhaps one day someone can put the effort in to writing a module to do all this.</p>
<p>James</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/10/11/perl-sharepoint/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Monday 6th October</title>
		<link>http://log.squish.net/2008/10/06/daily-links/</link>
		<comments>http://log.squish.net/2008/10/06/daily-links/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 22:50:03 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
The sky at night (and during the day) &#124; Gulliver &#124; Economist.com (tags: airline travel)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://www.economist.com/blogs/gulliver/2008/10/the_sky_at_night_and_during_th.cfm" title="The sky at night (and during the day) | Gulliver | Economist.com">The sky at night (and during the day) | Gulliver | Economist.com</a> (tags: <a href="http://del.icio.us/squish/airline">airline</a> <a href="http://del.icio.us/squish/travel">travel</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/10/06/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Monday 22nd September</title>
		<link>http://log.squish.net/2008/09/22/daily-links/</link>
		<comments>http://log.squish.net/2008/09/22/daily-links/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 22:50:02 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
How Wall Street Lied to Its Computers - Bits Blog - NYTimes.com (tags: news)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://bits.blogs.nytimes.com/2008/09/18/how-wall-streets-quants-lied-to-their-computers/?pagemode=print" title="How Wall Street Lied to Its Computers - Bits Blog - NYTimes.com">How Wall Street Lied to Its Computers - Bits Blog - NYTimes.com</a> (tags: <a href="http://del.icio.us/squish/news">news</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/09/22/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Friday 23rd May</title>
		<link>http://log.squish.net/2008/05/23/daily-links/</link>
		<comments>http://log.squish.net/2008/05/23/daily-links/#comments</comments>
		<pubDate>Fri, 23 May 2008 22:50:03 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
Shiny Shiny: Friday Video Fun: Alice in Wonderland does electronica (tags: disney music video)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://www.shinyshiny.tv/2008/05/friday_video_fu_43.html" title="Shiny Shiny: Friday Video Fun: Alice in Wonderland does electronica">Shiny Shiny: Friday Video Fun: Alice in Wonderland does electronica</a> (tags: <a href="http://del.icio.us/squish/disney">disney</a> <a href="http://del.icio.us/squish/music">music</a> <a href="http://del.icio.us/squish/video">video</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/05/23/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Wednesday 14th May</title>
		<link>http://log.squish.net/2008/05/14/daily-links/</link>
		<comments>http://log.squish.net/2008/05/14/daily-links/#comments</comments>
		<pubDate>Wed, 14 May 2008 22:50:04 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
Seven Misunderstandings About Classical Architecture (tags: architecture)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://www.qftarchitects.net/essays/seven.html" title="Seven Misunderstandings About Classical Architecture">Seven Misunderstandings About Classical Architecture</a> (tags: <a href="http://del.icio.us/squish/architecture">architecture</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/05/14/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Sunday 4th May</title>
		<link>http://log.squish.net/2008/05/04/daily-links/</link>
		<comments>http://log.squish.net/2008/05/04/daily-links/#comments</comments>
		<pubDate>Sun, 04 May 2008 22:50:03 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
The Matrix: Reloaded, Explained (tags: movies philosophy)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://wylfing.net/essays/matrix_reloaded.html" title="The Matrix: Reloaded, Explained">The Matrix: Reloaded, Explained</a> (tags: <a href="http://del.icio.us/squish/movies">movies</a> <a href="http://del.icio.us/squish/philosophy">philosophy</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/05/04/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Thursday 13th March</title>
		<link>http://log.squish.net/2008/03/13/daily-links-4/</link>
		<comments>http://log.squish.net/2008/03/13/daily-links-4/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 23:50:03 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<category><![CDATA[ramblings]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
Wireless Phone Jack &#8212; muuk - The New Technology Store (tags: gadgets network phone)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://www.muuk.co.uk/VoIP-&#038;-Telecom/Accessories/Wireless-Phone-Jack/p-91-94-447/" title="Wireless Phone Jack --- muuk - The New Technology Store">Wireless Phone Jack &#8212; muuk - The New Technology Store</a> (tags: <a href="http://del.icio.us/squish/gadgets">gadgets</a> <a href="http://del.icio.us/squish/network">network</a> <a href="http://del.icio.us/squish/phone">phone</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/03/13/daily-links-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Tuesday 11th March</title>
		<link>http://log.squish.net/2008/03/11/daily-links/</link>
		<comments>http://log.squish.net/2008/03/11/daily-links/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 23:50:03 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
Sony Vaio - Semi-Clean install &#124; Words Within (tags: reference)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://wordswithin.info/blog/?p=192" title="Sony Vaio - Semi-Clean install | Words Within">Sony Vaio - Semi-Clean install | Words Within</a> (tags: <a href="http://del.icio.us/squish/reference">reference</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/03/11/daily-links/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links for Tuesday 4th March</title>
		<link>http://log.squish.net/2008/03/04/daily-links/</link>
		<comments>http://log.squish.net/2008/03/04/daily-links/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 23:50:02 +0000</pubDate>
		<dc:creator>squish</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[ del.icio.us links:
Piccadilly Circus historic photos (tags: architecture history)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://del.icio.us/"><img src="/wp-content/themes/squish/delicious.small.gif" alt=""/></a> del.icio.us <a href="http://del.icio.us/squish">links</a>:</p>
<p><a href="http://www.guinntiques.com/piccadilly/piccadilly.asp" title="Piccadilly Circus historic photos">Piccadilly Circus historic photos</a> (tags: <a href="http://del.icio.us/squish/architecture">architecture</a> <a href="http://del.icio.us/squish/history">history</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://log.squish.net/2008/03/04/daily-links/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
