Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I upload a file from the local machine to Sharepoint using Perl SOAP::Lite?
    primarykey
    data
    text
    <pre><code>#use SOAP::Lite ( +trace =&gt; all, maptype =&gt; {} ); use SOAP::Lite maptype =&gt; {}; use LWP::UserAgent; use HTTP::Request::Common; #credentials' file require "c:\\test\\pass.pl"; my $userAgent = LWP::UserAgent-&gt;new(keep_alive =&gt; 1); sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $username =&gt; $password; } my $soap = SOAP::Lite -&gt;uri('&lt;mysite&gt;/_vti_bin/lists.asmx') -&gt;on_action(sub {join '/', 'http://schemas.microsoft.com/sharepoint/soap/CopyIntoItemsLocal', $_[1]}) -&gt;proxy('&lt;mysite&gt;/_layouts/viewlsts.aspx?BaseType=0', keep_alive =&gt; 1); # my $method = SOAP::Data-&gt;name('CopyIntoItemsLocal') # -&gt;attr({xmlns =&gt; 'http://schemas.microsoft.com/sharepoint/soap/'}); # my @params = (SOAP::Data-&gt;name(SourceUrl =&gt; $source), # SOAP::Data-&gt;name(DestinationUrl =&gt; $destination) ); # print $soap-&gt;call($method =&gt; @params)-&gt;result; my $fileName = 'c:\test\abc.txt'; my $destDir = "&lt;mysite&gt;/Lists/sharepoint1/"; #load and encode Data my $data; open(FILE, $fileName) or die "$!"; #read in chunks of 57 bytes to ensure no padding in the middle (Padding means extra space for large files) while (read(FILE, $buf, 60 * 57)) { $data .= encode_base64($buf); } close(FILE); #make the call print "uploading $fileName..."; $lists = $soap-&gt;GetList(); my $method = SOAP::Data-&gt;name('CopyIntoItemsLocal')-&gt;attr({xmlns =&gt; 'http://schemas.microsoft.com/sharepoint/soap/'}); my @params = ( SOAP::Data-&gt;name('SourceUrl')-&gt;value($fileName)-&gt;type(''), SOAP::Data-&gt;name('DestinationUrls')-&gt;type('')-&gt;value( \SOAP::Data-&gt;name('string')-&gt;type('')-&gt;value($destDir . $fileName) ), SOAP::Data-&gt;name('Fields')-&gt;type('')-&gt;value( \SOAP::Data-&gt;name('FieldInformation')-&gt;type('')-&gt;attr({Type =&gt; 'File'})-&gt;value('') ), SOAP::Data-&gt;name('Stream')-&gt;value("$data")-&gt;type('') ); #print Results print $soap-&gt;call($method =&gt; @params)-&gt;result; #print $response-&gt;headerof('//CopyResult')-&gt;attr-&gt;{ErrorCode}; </code></pre> <pre><code>#use SOAP::Lite ( +trace =&gt; all, maptype =&gt; {} ); use SOAP::Lite maptype =&gt; {}; use LWP::UserAgent; use HTTP::Request::Common; use MIME::Base64 qw(encode_base64); require "c:\\test\\pass.pl"; my $userAgent = LWP::UserAgent-&gt;new(keep_alive=&gt;1); #setup connection sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $username =&gt; $password; } my $soap = SOAP::Lite -&gt; uri('http://&lt;mysite&gt;') -&gt; on_action( sub{ join '/', 'http://schemas.microsoft.com/sharepoint/soap', $_[1] }) -&gt; proxy('http://&lt;mysite&gt;/_vti_bin/lists.asmx',keep_alive =&gt; 1); $lists = $soap-&gt;GetListCollection(); quit(1, $lists-&gt;faultstring()) if defined $lists-&gt;fault(); my @result = $lists-&gt;dataof('//GetListCollectionResult/Lists/List'); foreach my $data (@result) { my $attr = $data-&gt;attr; foreach my $a qw'Title Description DefaultViewUrl Name ID WebId ItemCount' { printf "%-16s %s\n", $a, $attr-&gt;{$a}; } print "\n"; } </code></pre> <p>The authentication seems to be working. First I thought that the <code>GetlistCollection</code> Web service is working, as when I made call using that Web service, it returned a page. But I think the call is returning the page I specified in the <code>proxy</code> argument.</p> <p>I am able to get the collection of list on the particular site on the sharepoint.</p> <p>I have used GetListCollection. However I did not really understand the code which is printing the list. I just copied it from <a href="http://www.squish.net/log/2008/10/11/perl-sharepoint/" rel="nofollow">squish.net</a>. Now I am trying to use the <code>CopyIntoItemsLocal</code> web service.</p> <p>We have a repository of files on one server (SVN) and I have to write a Perl script which when executed will copy the files and directories from SVN to sharepoint along with the directory structure.</p> <p>I will appreciate any help or tips. Since it is a big task, I am doing it in modules.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload