while($sth->fetch()) {
# zusatz scheint NULL zu sein...
if(!defined($zusatz)) {
$zusatz = "";
}
print("$id => $plz => $stadt => $kurzname => $zusatz => $status => $typ\n");
# Hash zusammenbasteln
my %hash;
$hash{"kurzname"} = $kurzname;
$hash{"plz"} = $plz;
$hash{"stadt"} = $stadt;
$hash{"status"} = $status;
$hash{"typ"} = $typ;
$hash{"zusatz"} = $zusatz;
push(@ary,\%hash);
}
$sth->finish();
# evtl. Fehlerbehandlung
my $laenge = @ary;
if($laenge > 0) {
eval {
print("DataSyncTool: @ary\n");
$dss->updatePLZInformationen(\@ary); # $dss = instance of data_service.pm
};
if($@) {
# Fehler ausgeben
chop($@);
if($debug == 1) { &debug_out("updatePLZInformationen => FEHLER:\n$@\n") };
$err_txt .= "updatePLZInformationen => FEHLER:\n$@\n";
}
}
####
sub updatePLZInformationen() {
# überträgt geänderte PLZ-Daten
my $data = shift;
print("Yeehah: $data\n");
my $plz = SOAP::Lite
-> service('file:/home/orca/oracle/DataSyncTool/config/SKADataService.wsdl');
$plz->updatePLZInformationen(
SOAP::Data->type("xsd:string")->name("clientid" => "ska")->value,
SOAP::Data->type("xsd:string")->name("securitytoken" => "ska")->value,
SOAP::Data->type("tns2:PLZInfo")->name("plzinfos")->value(
\SOAP::Data->value(
&format_plz_infos($data)
)
)
);
}
# ------------------------------------------------------------------------------------------------ #
sub format_plz_infos() {
# formatiert den komplexen Typ "plzinfo"
my $plz = shift;
my @plz_info;
print("Yeehah: $plz\n");
foreach(@$plz) {
my $hash = $_;
push(@plz_info,SOAP::Data->name("kurzname")->value($hash->{"kurzname"})->type("xsd:string"));
push(@plz_info,SOAP::Data->name("plz")->value($hash->{"plz"})->type("xsd:string"));
push(@plz_info,SOAP::Data->name("stadt")->value($hash->{"stadt"})->type("xsd:string"));
push(@plz_info,SOAP::Data->name("status")->value($hash->{"status"})->type("xsd:string"));
push(@plz_info,SOAP::Data->name("typ")->value($hash->{"typ"})->type("xsd:string"));
push(@plz_info,SOAP::Data->name("zusatz")->value($hash->{"zusatz"})->type("xsd:string"));
}
return(@plz_info);
}
# ------------------------------------------------------------------------------------------------ #
####
test@testmachine:~/test/DataSyncTool> ./data_sync_tool.pl
16:12:2008 09:14:13, DEBUG: Programm gestartet...
16:12:2008 09:14:13, DEBUG: updatePLZInformationen => Data of plz table:
1 => 01001 => Dresden => Dresden => => 1 => 3
2 => 01002 => Dresden => Dresden => => 1 => 3
3 => 01003 => Dresden => Dresden => => 1 => 3
4 => 01004 => Dresden => Dresden => => 1 => 3
DataSyncTool: HASH(0x86d81f8) HASH(0x8740d38) HASH(0x88058c0) HASH(0x8805920)
Yeehah: DatenService=HASH(0x8743344)
Yeehah: DatenService=HASH(0x8743344)
16:12:2008 09:14:13, DEBUG: updatePLZInformationen => FEHLER:
Not an ARRAY reference at data_service.pm line 161.
16:12:2008 09:14:13, DEBUG: updatePLZInformationen => Fertig.
####
foreach(@$plz) {
...
}