Hi,
Got a weird problem with this script :/ It seems to die around here;
print "bad " . $response->status_line . "\n";
}
...which gives;
"bad: 500 Internal Server Error"
#
#
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use LWP::UserAgent;
use HTTP::Request;
use XML::Parser;
use DBI;
my $cfg;
$cfg->{script_path} = './';
my $DEBUG = 1;
my $IN = new CGI;
print $IN->header();
my $query = qq|
<APC_Search_Query>
<WebSiteID>177783</WebSiteID>
<PageNumber>1</PageNumber>
<ProductsPerPage>15</ProductsPerPage>
<CategoryID>623</CategoryID>
<SortOrder>R</SortOrder>
<SearchText>Matrix</SearchText>
<inWidth>5</MinWidth>
<MaxWidth>30</MaxWidth>
<MinHeight>10</MinHeight>
<MaxHeight>60</MaxHeight>
<MinPrice></MinPrice>
<MaxPrice>50</MaxPrice>
</APC_Search_Query>
|;
$query =~ s/\n//sig; # only leave newlines in for pretty stuff =)
$query =~ s/\s+//sig; # only leave newlines in for pretty stuff =)
print "Query: $query";
print SoapPosters($query);
sub SoapPosters
{
my $sendxml = shift;
my $result = '';
my $content = qq{
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<GetProductInformation
xmlns="http://Webservice.Allposters.com/APCF.AffiliateWebService/ProductInformationService">
<APCSearchXml>
<![CDATA[$sendxml]]>
</APCSearchXml>
</GetProductInformation>
</soap:Body>
</soap:Envelope>
};
my $result;
my $ua = LWP::UserAgent->new();
my $request = HTTP::Request->new(POST => 'http://webservice.allposters.com/ProductInformationService.asmx');
$request->header(SOAPAction => '"http://webservice.allposters.com/APCF.AffiliateWebService/ProductInformationService/GetProductInformation"');
$request->content($content);
$request->content_type("text/xml; charset=utf-8");
my $response = $ua->request($request);
if ($response->is_success) {
my $responeXml = $response->content;
my $xmlp = new XML::Parser(Handlers => {Start => \&StartGetProductInformationResponse,
End => \&EndGetProductInformationResponse,
Char => \&CharGetProductInformationResponse
},
'Non-Expat-Options' => {xmlResult => \$result}
);
eval {$xmlp->parse($responeXml)};
if ($@) {
$result = '';
}
} else {
print "bad " . $response->status_line . "\n";
}
return $result;
}
sub StartGetProductInformationResponse {
my $e = shift;
${$e->{'Non-Expat-Options'}{'xmlResult'}} = '';
my $tag = shift;
if ($tag eq 'GetProductInformationResult') {
$e->{'Non-Expat-Options'}{'GetProductInformationResult'} = 1;
}
}
sub CharGetProductInformationResponse {
my $e = shift;
my $val = shift;
if ($e->{'Non-Expat-Options'}{'GetProductInformationResult'}) {
${$e->{'Non-Expat-Options'}{'xmlResult'}} .= $val;
}
}
sub EndGetProductInformationResponse {
my $e = shift;
my $tag = shift;
if ($tag eq 'GetProductInformationResult') {
$e->{'Non-Expat-Options'}{'GetProductInformationResult'} = 0;
}
}
###########################################################
# Sub for getting the date....
sub date {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime();
my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
1;
Is this a problem my end, or AllPosters?
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Got a weird problem with this script :/ It seems to die around here;
Code:
} else { print "bad " . $response->status_line . "\n";
}
...which gives;
"bad: 500 Internal Server Error"
Code:
#!/usr/local/bin/perl #
#
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use LWP::UserAgent;
use HTTP::Request;
use XML::Parser;
use DBI;
my $cfg;
$cfg->{script_path} = './';
my $DEBUG = 1;
my $IN = new CGI;
print $IN->header();
my $query = qq|
<APC_Search_Query>
<WebSiteID>177783</WebSiteID>
<PageNumber>1</PageNumber>
<ProductsPerPage>15</ProductsPerPage>
<CategoryID>623</CategoryID>
<SortOrder>R</SortOrder>
<SearchText>Matrix</SearchText>
<inWidth>5</MinWidth>
<MaxWidth>30</MaxWidth>
<MinHeight>10</MinHeight>
<MaxHeight>60</MaxHeight>
<MinPrice></MinPrice>
<MaxPrice>50</MaxPrice>
</APC_Search_Query>
|;
$query =~ s/\n//sig; # only leave newlines in for pretty stuff =)
$query =~ s/\s+//sig; # only leave newlines in for pretty stuff =)
print "Query: $query";
print SoapPosters($query);
sub SoapPosters
{
my $sendxml = shift;
my $result = '';
my $content = qq{
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<GetProductInformation
xmlns="http://Webservice.Allposters.com/APCF.AffiliateWebService/ProductInformationService">
<APCSearchXml>
<![CDATA[$sendxml]]>
</APCSearchXml>
</GetProductInformation>
</soap:Body>
</soap:Envelope>
};
my $result;
my $ua = LWP::UserAgent->new();
my $request = HTTP::Request->new(POST => 'http://webservice.allposters.com/ProductInformationService.asmx');
$request->header(SOAPAction => '"http://webservice.allposters.com/APCF.AffiliateWebService/ProductInformationService/GetProductInformation"');
$request->content($content);
$request->content_type("text/xml; charset=utf-8");
my $response = $ua->request($request);
if ($response->is_success) {
my $responeXml = $response->content;
my $xmlp = new XML::Parser(Handlers => {Start => \&StartGetProductInformationResponse,
End => \&EndGetProductInformationResponse,
Char => \&CharGetProductInformationResponse
},
'Non-Expat-Options' => {xmlResult => \$result}
);
eval {$xmlp->parse($responeXml)};
if ($@) {
$result = '';
}
} else {
print "bad " . $response->status_line . "\n";
}
return $result;
}
sub StartGetProductInformationResponse {
my $e = shift;
${$e->{'Non-Expat-Options'}{'xmlResult'}} = '';
my $tag = shift;
if ($tag eq 'GetProductInformationResult') {
$e->{'Non-Expat-Options'}{'GetProductInformationResult'} = 1;
}
}
sub CharGetProductInformationResponse {
my $e = shift;
my $val = shift;
if ($e->{'Non-Expat-Options'}{'GetProductInformationResult'}) {
${$e->{'Non-Expat-Options'}{'xmlResult'}} .= $val;
}
}
sub EndGetProductInformationResponse {
my $e = shift;
my $tag = shift;
if ($tag eq 'GetProductInformationResult') {
$e->{'Non-Expat-Options'}{'GetProductInformationResult'} = 0;
}
}
###########################################################
# Sub for getting the date....
sub date {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime();
my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
1;
Is this a problem my end, or AllPosters?
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

