| Code: |
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
use XML::Parser;
print SendSOAPAllPosters('
<APC_Search_Query>
<WebSiteID>177783</WebSiteID>
<PageNumber>1</PageNumber>
<ProductsPerPage>15</ProductsPerPage>
<CategoryID>101</CategoryID>
<SearchText>Matrix</SearchText>
<SortOrder>R</SortOrder>
<MinWidth>5</MinWidth>
<MaxWidth>30</MaxWidth>
<MinHeight>10</MinHeight>
<MaxHeight>60</MaxHeight>
<MinPrice></MinPrice>
<MaxPrice>50</MaxPrice>
</APC_Search_Query>
');
sub SendSOAPAllPosters {
my $sendxml = shift;
my $result = '';
my $content = <<CONTENT
<?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>
CONTENT ;
$ua = LWP::UserAgent->new();
$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"); $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\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;
}
}
1;
|