|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
roci - WebService
This is a short introduction using roci WebServices offered by
BiBiServ. If you're not familiar with using webservices in
general you should have a closer look to our webservice related
linklist.
WSDL - methods, parameters and datatypes
If you've a closer look at the WSDL file describing the roci webservice,
you can see two methods belonging together.
request_orig
response_orig Example Perl clients
The example perl client implementation for all methods is based
on SOAP::Lite.
Example Client for the requestOrig method (Download Source): #!/usr/bin/env perl use SOAP::Lite; use Data::Dumper; use Getopt::Long; use Encode; use utf8; #production system $wsdlurl = "http://bibiserv.techfak.uni-bielefeld.de/wsdl/roci.wsdl"; #test system #$wsdlurl = "http://bibitest.techfak.uni-bielefeld.de/wsdl/roci.wsdl"; my $a; #Extended search space my $v; #verbose mode my $inputfile = ""; my $email=""; GetOptions("a" => \$a, #boolean "v" => \$v, #boolean "inputfile=s" => \$inputfile, #file "email=s" => \$email #String ); if($inputfile eq ""){ print "At least inputfile must be given! (-inputfile <filename>)\n"; exit 1; } my $input = readFile($inputfile); $input = encode('utf8', $input); my @params; if($a){ @params = (@params, "a", SOAP::Data->type(boolean => $a)); } if($v){ @params = (@params, "v", SOAP::Data->type(boolean => $v)); } if($email ne ""){ @params =(@params, "email", SOAP::Data->type(string => $email)); } print "Submitting your request ...\n"; $result = SOAP::Lite->service($wsdlurl) ->on_fault(sub {soapFaultHandler(@_)}) ->request_orig(SOAP::Data->type(string=>$input), \@params); print "got id: '$result'\n"; sub soapFaultHandler { print "\n Error:\n"; my($soap, $res) = @_; if (ref $res) { print "Statuscode:".$res->faultcode."\n"; print "Description:".$res->faultstring."\n"; $detail = $res->faultdetail; if(defined($detail->{"hobitStatuscode"})) { print Dumper $detail->{"hobitStatuscode"}->{"statuscode"}; print Dumper $detail->{"hobitStatuscode"}->{"description"}; } else { print "Sevlet Error - no Hobit Statuscode\n"; } } else { print "http layer Error: "; print $soap->transport->status; } exit 1; } sub readFile{ my $file = shift; my $content = ""; open(FILE, $file) or die("Cannot open file $file !"); foreach my $line (<FILE>){ $content .= $line; } close FILE; return $content; } Example Client for the responseOrig method (Download Source): #!/usr/bin/env perl use SOAP::Lite; use Data::Dumper; #production system $wsdlurl = "http://bibiserv.techfak.uni-bielefeld.de/wsdl/roci.wsdl"; #test system #$wsdlurl = "http://bibitest.techfak.uni-bielefeld.de/wsdl/roci.wsdl"; if(!defined $ARGV[0]) { print "call with id\n"; exit 1; } print "Submitting your id... "; $result = SOAP::Lite->service($wsdlurl) ->on_fault(sub {soapFaultHandler(@_)}) ->response_orig($ARGV[0]); print Dumper $result; sub soapFaultHandler { my($soap, $res) = @_; if (ref $res) { print "Statuscode:".$res->faultcode."\n"; print "Description:".$res->faultstring."\n"; $detail = $res->faultdetail; print Dumper $detail->{"hobitStatuscode"}->{"statuscode"}; print Dumper $detail->{"hobitStatuscode"}->{"description"}; } else { print "http layer Error: "; print $soap->transport->status; } exit 1; } |
|
|||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||