2 # Query the DB0SDX QSL server for a callsign
4 # Copyright (c) 2003 Dirk Koopman G1TLH
5 # Modified Dec 9, 2004 for new website and xml schema by David Spoelstra N9KT
6 # and tidied up by me (Dirk)
13 my ($self, $line) = @_;
14 my $call = $self->call;
18 return (1, $self->msg('e24')) unless $Internet::allow;
19 return (1, "SHOW/DB0SDX <callsign>, e.g. SH/DB0SDX ea7wa") unless $line && is_callsign($line);
20 my $target = $Internet::db0sdx_url || 'www.qslinfo.de';
21 my $path = $Internet::db0sdx_path || '/qslinfo';
22 my $suffix = $Internet::db0sdx_suffix || '.asmx';
24 my $cmdprompt = '/query->.*$/';
30 dbg("db0sdx: contacting $target:$port") if isdbg('db0sdx');
31 $info = $t->open(Host => $target,
36 push @out, $self->msg('e18', 'DB0SDX Database server');
39 dbg("db0sdx: connected to $target:$port") if isdbg('db0sdx');
41 my $s = qq(<?xml version="1.0" encoding="utf-8"?>
42 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
44 <qslinfo xmlns="http://$target">
45 <callsign>$line</callsign>
46 <ClientInformation>DXSpider V$main::version B$main::build ($call\@$main::mycall)</ClientInformation>
53 my $lth = length($s)+7;
55 dbg("db0sdx out: $s") if isdbg('db0sdx');
57 $t->print("POST $path$suffix HTTP/1.0");
58 $t->print("Host: $target");
59 $t->print("Content-Type: text/xml; charset=utf-8");
60 $t->print("Content-Length: $lth");
61 $t->print("Connection: Close");
62 $t->print(qq{SOAPAction: "http://$target$path"});
68 while (my $result = eval { $t->getline(Timeout => 30) } || $@) {
70 push @out, $self->msg('e18', 'DB0SDX Server');
77 dbg("db0sdx in: $in") if isdbg('db0sdx');
80 Log('call', "$call: show/db0sdx $line");
83 my ($info) = $in =~ m|<qslinfoResult>([^<]*)</qslinfoResult>|;
84 my @in = split /[\r\n]/, $info if $info;
88 ($info) = $in =~ m|<faultstring>([^<]*)</faultstring>|;
89 push @out, $info if $info;
90 push @out, $self->msg('e3', 'DB0SDX', $line) unless @out;