Gossamer Forum
Home : General : Perl Programming :

SOAP Problems :(

Quote Reply
SOAP Problems :(
Hi,

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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread SOAP Problems :( Andy 11418 Apr 27, 2005, 1:13 AM
Thread Re: [Andy] SOAP Problems :(
Wil 11304 Apr 27, 2005, 3:33 AM
Thread Re: [Wil] SOAP Problems :(
Andy 11279 Apr 27, 2005, 3:52 AM
Thread Re: [Andy] SOAP Problems :(
Wil 11253 Apr 27, 2005, 8:10 AM
Thread Re: [Wil] SOAP Problems :(
Andy 11222 Apr 27, 2005, 8:14 AM
Thread Re: [Andy] SOAP Problems :(
Wil 11246 Apr 28, 2005, 2:33 AM
Thread Re: [Wil] SOAP Problems :(
Andy 11210 Apr 28, 2005, 3:25 AM
Post Re: [Andy] SOAP Problems :(
Wil 11210 Apr 28, 2005, 8:35 AM