• perl & soap to create a document

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #1352  by justroll
 
hi

i\'m trying to use perl to create a document in openkm; although my knowledge to OOP is limited i wrote the following (which is working UNTIL the creation part)
Code: Select all
#!/usr/bin/perl

use strict;
use SOAP::Lite;
use Data::Dumper;
use MIME::Base64 qw(en_base64);
#   local($/) = undef;  # slurp
#   print en_base64(<STDIN>);
use Document;

use SOAP::Lite +trace => qw (debug);
my $resp;

my $PartnersWS = SOAP::Lite->service(\'http://localhost:8080/OpenKM/OKMAuth?wsdl\');
my $token = $PartnersWS->login(\'admin\',\'admin\');

print \"---\";
my $buff=\"\";my $buf;
   open(FILE, \"/var/log/wtmp\") or die \"$!\";
my $doc = new Document(\'/okm:root/testfolder/wtmp.txt2\',\'admin\');
my $file=$PartnersWS1->create($token,$doc,$buff);
my $res = $PartnersWS->logout($token);
---
Document.pm looks like
Code: Select all
#!/usr/bin/perl 

package Document;

sub new
{
    my $class = shift;
    my $self = {
        path => shift,
        author  => shift,
    };
    bless $self, $class;
    return $self;
}
sub setPath {
    my ( $self, $path ) = @_;
    $self->{path} = $path if defined($path);
    return $self->{path};
}

sub getPath {
    my( $self ) = @_;
    return $self->{path};
}
1;
--

Point is when sending the soap. .nothing comes in the soap call

look ..
Code: Select all
Dumper($doc)

$VAR1 = bless( {
                 \'author\' => \'admin\',
                 \'path\' => \'/okm:root/testfolder/wtmp.txt2\'
               }, \'Document\' );
----
actual soap call
Code: Select all
SOAP::Transport::HTTP::Client::send_receive: POST http://127.0.0.1:8080/OpenKM/OKMDocument HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 6755
Content-Type: text/xml; charset=utf-8
SOAPAction: \"\"

<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tns=\"http://endpoint.ws.openkm.git.es/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><tns:create><arg0 xsi:type=\"xsd:string\">1129287567495677636285-19554898471</arg0>[color=#FF0000]<arg1 xsi:nil=\"true\" xsi:type=\"tns:document\" />[/color]<arg2 xsi:type=\"xsd:base64Binary\">QlFBQUFHcGVBQUF....</arg2></tns:create></soap:Body></soap:Envelope>
can anyone please help me ?
 #3409  by nicolaijorgensen
 
Hi!

I\'ve tried every possible idea with SOAP::Lite and I just can\'t get anything working with complex structs like tns:folder.

In stead I\'ve managed to get the Folder create function working in perl. It\'s not pretty but it\'s worth sharing IMHO

EDIT: Sorry, but I can\'t copy/paste my script. I get an error \"invalid access\" when I try. Have tried Quote and Code tags without luck...
EDIT2: I\'ve posted the code to my website here:
http://www.pvr.dk/openkm.html

To use, call like this with a valid login TOKEN:
script.pl \"http://localhost:8080/OpenKM/OKMFolder\" TOKEN \"/okm:root/FolderToCreate\"

/Nicolai

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.