Hello Anonymous,
What do you mean by:
I'm trying to see if there are any examples out there on SOAP::Lite that illustrate how to update or insert data into the web service.
From DEFAULT SETTINGS of the SOAP::Lite module.
If you wish to provide common proxy() or uri() settings for all SOAP::Lite objects in your application you may do:
use SOAP::Lite
proxy => 'http://localhost/cgi-bin/soap.cgi',
uri => 'http://my.own.com/My/Examples';
my $soap1 = new SOAP::Lite; # will get the same proxy()/uri() as abo
+ve
print $soap1->getStateName(1)->result;
my $soap2 = SOAP::Lite->new; # same thing as above
print $soap2->getStateName(2)->result;
# or you may override any settings you want
my $soap3 = SOAP::Lite->proxy('http://localhost/');
print $soap3->getStateName(1)->result;
Any SOAP::Lite properties can be propagated this way. Changes in object copies will not affect global settings and you may still change global settings with SOAP::Lite->self call which returns reference to global object. Provided parameter will update this object and you can even set it to undef:
SOAP::Lite->self(undef);
There is also simple basic tutorial if you want to take a look here SOAP::Lite for Perl, with code samples.
Update: Based on your update:
If not, is there another module that uses a WSDL and can insert/update?
I also found this SOAP, WSDL, XML service/client relative question that on the forum that might give one or several answer(s) to your question(s).
Update 2: I found a server and client script that I wrote about 3-4 years ago. I think it does still work. I do not have the time to tested but I remember that was working before. I think it is just what you ask.
Server side:
#!/usr/bin/perl
#SOAP SERVER
use DBI;
use strict;
use warnings;
use SOAP::Lite;
use SOAP::Transport::HTTP;
my $daemon = SOAP::Transport::HTTP::Daemon->new(LocalAddr => 'localhos
+t', => LocalPort => 9005,Reuse=>1);
$daemon->dispatch_to('Todo');
print "Contact to SOAP server at ", $daemon->url, "\n";
$daemon->handle();
package Todo;
my $usrname = 'student';
my $passwrd = '1qaz2wsx';
#geToDoList Method
sub getTodoList{
print "getToDoList method invoked by client \n";
my ($method,$acronym) = @_;
my $dbh = DBI->connect('DBI:mysql:organize:localhost:9005',$usrnam
+e,$passwrd)
or die "Failed to connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM todo WHERE user = ?')
or die "Couldn't prepare statement: " . $dbh->errstr;
my @toDoDataArray;
$sth->execute($acronym)
or die "Couldn't execute statement: " . $sth->errstr;
my @my_array;
while (@toDoDataArray = $sth->fetchrow_array()) {
my $response = SOAP::Data->name(
"getTodoListResponse" => \SOAP::Data->value(
SOAP::Data->name(
"getTodoListResult" => \SOAP::Data->value(
SOAP::Data->name(
"TodoData"=>\SOAP::Data->value(
SOAP::Data->name('user' => $toDoDataArray[4]),
SOAP::Data->name('date' => $toDoDataArray[2]),
SOAP::Data->name('note' => $toDoDataArray[1]),
SOAP::Data->name('prio' => $toDoDataArray[3]),
SOAP::Data->name('id' => $toDoDataArray[0])
)
)
)
)
)
);
push (@my_array,$response);
}
$dbh->disconnect();
return @my_array;
}
#getTodoOneDay Method
sub getTodoOneDay{
print "getTodoOneDay method invoked by client \n";
my ($method,$acronym,$date) = @_;
my $dbh = DBI->connect('DBI:mysql:organize:localhost:9005',$usrnam
+e,$passwrd)
or die "Failed to connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM todo WHERE user = ? AND dat
+e = ?')
or die "Failed to prepare statement: " . $dbh->errstr;
my @toDoDataArray;
$sth->execute($acronym,$date)
or die "Failed to execute statement: " . $sth->errstr;
my @my_array;
while (@toDoDataArray = $sth->fetchrow_array()) {
my $response = SOAP::Data->name(
"getTodoListResponse" => \SOAP::Data->value(
SOAP::Data->name(
"getTodoListResult" => \SOAP::Data->value(
SOAP::Data->name(
"TodoData"=>\SOAP::Data->value(
SOAP::Data->name('user' => $toDoDataArray[4]),
SOAP::Data->name('date' => $toDoDataArray[2]),
SOAP::Data->name('note' => $toDoDataArray[1]),
SOAP::Data->name('prio' => $toDoDataArray[3]),
SOAP::Data->name('id' => $toDoDataArray[0])
)
)
)
)
)
);
push (@my_array,$response);
}
$dbh->disconnect();
return @my_array;
}
#createToDo Method
sub createTodo{
print "createToDo method invoked by client \n";
my ($method,$acronym,$date,$note,$priority,$id) = @_;
my $dbh = DBI->connect('DBI:mysql:organize:localhost:9005','root',
+'jimma1503')
or die "Failed connect to database: " . DBI->errstr;
my $query="INSERT INTO todo (id,note,date,prio,user) VALUES ('$id'
+,'$note','$date','$priority','$acronym')";
my $sth = $dbh->prepare($query)
|| die "prepare: $query: $DBI::errstr";
$sth->execute || die "execute: $query: $DBI::errstr";
$dbh->disconnect();
return "INSERTED";
}
#deletetodo Method
sub deleteTodo {
print "deleteToDo method invoked by client \n";
my($method,$acronym,$id)=@_;
my $dbh = DBI->connect('DBI:mysql:organize:localhost:9005','root',
+'jimma1503')
or die "Failed to connect to database: " . DBI->errstr;
my $sth = $dbh->prepare("DELETE FROM todo WHERE user = ? AND id=?"
+);
$sth->execute($acronym,$id ) or die $DBI::errstr;
$sth->finish();
$dbh->disconnect();
return "DELETED";
}
#updateTodo Method
sub updateTodo {
print "updateTodo method invoked by client \n";
my($method,$acronym,$time,$note,$priority,$id)=@_;
my $dbh = DBI->connect('DBI:mysql:organize:localhost:9002','$usrna
+me','$password')
or die "Failed to connect to database: " . DBI->errstr;
my $sth = $dbh->prepare( 'UPDATE todo SET user=?, date=?, note=?,
+prio=? WHERE id=?' );
$sth->execute($acronym,$time,$note,$priority,$id)
or die ( "Error on UPDATE: $DBI::errstr\n" );
$sth->finish();
$dbh->disconnect();
return "UPDATED";
}
Client createtodo:
#!/usr/bin/perl
use strict 'vars'; #this is to protect unquotted string,bareword which
+ come from Soap trace
use warnings;
use SOAP::Lite + trace;
my $thay =SOAP::Lite->new();
$thay->proxy('http://localhost:9002');
$thay->uri('Todo');
print "Enter Your Acronym:\n";
my $acro=<STDIN>;
chomp $acro;
print "Enter Time(YYYY-MM-DD-hr:MM)\n";
my $time=<STDIN>;
chomp $time;
print "Enter a text to your ToDoList\n";
my $text=<STDIN>;
chomp $text;
print "Enter The Priority your ToDoList(1-10)\n";
my $prio=<STDIN>;
chomp $prio;
my $data =$thay->call(
createTodo=>(
SOAP::Data->name("acronym")->value("$acro"),SOAP::Data->name("time
+")->value("$time"),
SOAP::Data->name("note")->value("$text"),SOAP::Data->name("priorit
+y")->value("$prio")
)
);
Client deletetodo:
#!/usr/bin/perl
use strict 'vars'; #this is to protect unquotted string,bareword which
+ come from Soap trace
use warningns;
use SOAP::Lite +trace;
my $thay =SOAP::Lite->new();
$thay->proxy('http://localhost:9002');
$thay->uri('Todo');
print "Enter Your Acronym to be Deleted:\n";
my $acro=<STDIN>;
chomp $acro;
print "Enter the ID\n";
my $id=<STDIN>;
chomp $id;
my $data = $thay->call(
deleteTodo=>(
SOAP::Data->name("acronym")->value("$acro"),
SOAP::Data->name("id")->value("$id")
)
);
Client gettodolist:
#!/usr/bin/perl
#getTodoList
use strict 'vars'; #this is to protect unquotted string,bareword which
+ come from Soap trace
use warnings;
use SOAP::Lite +trace;
my $thay =SOAP::Lite->new();
$thay->proxy('http://localhost:9002');
$thay->uri('Todo');
print "Enter an Acronym to get list of the ToDolist:\n";
my $acro=<STDIN>;
chomp $acro;
my $data =$thay->call(
getTodoList=>(
SOAP::Data->name("acronym")->value("$acro")
)
);
Client updatetodo:
#!/usr/bin/perl
#updateTdo
use warnings;
use strict 'vars';#this is to protect unquotted string,bareword which
+come from Soap trace
use SOAP::Lite +trace;
my $thay =SOAP::Lite->new();
$thay->proxy('http://localhost:9002');
$thay->uri('Todo');
print "Enter Your to Update Acronym:\n";
my $acro=<STDIN>;
chomp $acro;
print "Enter ID\n";
my $id=<STDIN>;
chomp $id;
print "Enter updated Time(YYYY-MM-DD-hr:MM)\n";
my $time=<STDIN>;
chomp $time;
print "Enter a updated text to your ToDoList\n";
my $text=<STDIN>;
chomp $text;
print "Enter The new Priority your ToDoList(1-10)\n";
my $prio=<STDIN>;
chomp $prio;
my $data = $thay->call(
updateTodo=>( SOAP::Data->name("acronym")->value("$acro"),
SOAP::Data->name("time")->value("$time"),
SOAP::Data->name("note")->value("$text"),
SOAP::Data->name("priority")->value("$prio"),
SOAP::Data->name("id")->value("$id")
)
);
Again, in the past this code use to work, I do not have the time to debug it or test it (sorry).
Hope this helps.
Seeking for Perl wisdom...on the process of learning...not there...yet!
|