ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
sub SendSOAPDetailedPoster { my $sendxml = qq| <APC_Search_Query> <WebSiteID>$ALLPOSTERSID</WebSiteID> <SearchTerm>5024381</SearchTerm> <LanguageID>3</LanguageID> </APC_Search_Query> |; my $query = <<CONTENT <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schema +s.xmlsoap.org/soap/envelope/"> <soap:Body> <GetProductByProductNumberInformation xmlns="http://Webservice.Allposters.com/APCF.AffiliateWebService/Produ +ctInformationService"> <APCSearchXml> <![CDATA[$sendxml]]> </APCSearchXml> </GetProductInformation> </soap:Body> </soap:Envelope> CONTENT ; print "QUERY: $query"; my $ua = LWP::UserAgent->new(); my $request = HTTP::Request->new(POST => 'http://webservice.allpos +ters.com/ProductInformationService.asmx'); # "http://Webservice.Allposters.com +/APCF.AffiliateWebService/ProductInformationService/GetProductByProdu +ctNumberInformation" $request->header(SOAPAction => '"http://Webservice.Allposters.com/ +APCF.AffiliateWebService/ProductInformationService/GetProductByProduc +tNumberInformation"'); $request->content($query); $request->content_type("text/xml; charset=utf-8"); my $response = $ua->request($request); if ($response->is_success) { my $content = $response->content; $content =~ s/</</sig; $content =~ s/>/>/sig; my $refs = XMLin($content); my $results = $refs->{"soap:Body"}->{GetProductInformationResp +onse}->{GetProductInformationResult}->{APC_Search_Results}->{Search_R +esult}; #print Dumper($refs->{"soap:Body"}->{GetProductInformationResponse}->{ +GetProductInformationResult}->{APC_Search_Results}); my $products = $results->{Products}->{ProductInformation}; my $per_page = $results->{No_Of_Products_In_Current_Page}; my $num_results = $results->{Total_No_Of_Products}; my $current_page = $results->{Current_PageNumber}; my $num_pages; if ($num_results > 0) { $num_pages = ceil($num_results / $per_page); } else { $num_pages = 0; } $num_results = DatafeedSQL::commify($num_results); use Data::Dumper; print Dumper($products); return ($per_page,$num_results,$current_page,$num_pages,$produ +cts); } else { print "ERROR: " . $response->status_line; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Anyone got the AllPosters SOAP webservice working?
by Anonymous Monk on Mar 10, 2010 at 04:36 UTC |