| 1 | use SOAP::Lite; | ||
| 2 | { package SOAP::Lite; | ||
| 3 | # This is exactly the same as SOAP::Lite::service, except that %services is saved in {'_serviceDefs'} | ||
| 4 | no warnings; | ||
| 5 | sub service { | ||
| 6 | my $field = '_service'; | ||
| 7 | my $self = shift->new; | ||
| 8 | return $self->{$field} unless @_; | ||
| 9 | |||
| 10 | my %services = %{SOAP::Schema->schema($self->{$field} = shift)->parse(@_)->load->services}; | ||
| 11 | Carp::croak "Cannot activate service description with multiple services through this interface\n" | ||
| 12 | if keys %services > 1; | ||
| 13 | |||
| 14 | my $rtn = (keys %services)[0]->new; | ||
| 15 | $rtn->{'_servicesDef'} = \%services; | ||
| 16 | return $rtn; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | package WWW::Scraper::WSDL; | ||
| 21 | |||
| 22 | |||
| 23 | ##################################################################### | ||
| 24 | |||
| 25 | require Exporter; | ||
| 26 | @EXPORT = qw(); | ||
| 27 | @EXPORT_OK = qw(trimTags); | ||
| 28 | use vars qw($VERSION @ISA); | ||
| 29 | @ISA = qw(WWW::Scraper Exporter); | ||
| 30 | $VERSION = sprintf("%d.%02d", q$Revision: 1.0 $ =~ /(\d+)\.(\d+)/); | ||
| 31 | |||
| 32 | use Carp (); | ||
| 33 | use WWW::Scraper(qw(2.22)); | ||
| 34 | use WWW::Scraper::Request::WSDL; | ||
| 35 | use strict; | ||
| 36 | |||
| 37 | |||
| 38 | my $scraperRequest = | ||
| 39 | { | ||
| 40 | 'type' => 'WSDL' | ||
| 41 | # ,'formNameOrNumber' => undef | ||
| 42 | # ,'submitButton' => 'Submit' | ||
| 43 | |||
| 44 | # This is the basic URL on which to get the form to build the query. | ||
| 45 | # ,'url' => 'http://www.usps.com/ncsc/lookups/lookup_zip+4.html' | ||
| 46 | ,'url' => 'http://www.xmethods.net/sd/StockQuoteService.wsdl' | ||
| 47 | # specify defaults, by native field names | ||
| 48 | # ,'nativeQuery' => 'Delivery+Address' | ||
| 49 | ,'nativeDefaults' => { | ||
| 50 | } | ||
| 51 | |||
| 52 | # specify translations from canonical fields to native fields | ||
| 53 | ,'defaultRequestClass' => 'WSDL' | ||
| 54 | ,'fieldTranslations' => | ||
| 55 | { | ||
| 56 | '*' => | ||
| 57 | { | ||
| 58 | '*' => '*' | ||
| 59 | } | ||
| 60 | } | ||
| 61 | # Miscellaneous options for the Scraper operation. | ||
| 62 | }; | ||
| 63 | |||
| 64 | sub new { | ||
| 65 | my ($subclass, $serviceAdr, $native_query, $native_options) = @_; | ||
| 66 | |||
| 67 | my ($self, $wantsNativeRequest); | ||
| 68 | $wantsNativeRequest = $subclass =~ s/^NativeRequest\:\:(.*)$/$1/; | ||
| 69 | $self = {}; | ||
| 70 | bless $self, 'WWW::Scraper::WSDL'; | ||
| 71 | $self->_wantsNativeRequest($wantsNativeRequest); | ||
| 72 | |||
| 73 | $self->{'agent_name'} = "Mozilla/WWW::Scraper::WSDL/$VERSION"; | ||
| 74 | $self->{'agent_e_mail'} = 'glenwood@alumni.caltech.edu;MartinThurn@iname.com'; | ||
| 75 | |||
| 76 | $self->{'scraperQF'} = 0; # Explicitly declare 'scraperQF' as the deprecated mode. | ||
| 77 | $self->{'scraperName'} = 'WSDL'; | ||
| 78 | |||
| 79 | $self->{cache} = []; # This eliminates some useless "warnings" from WWW::Search(lines 544-549) during make test. | ||
| 80 | # Finally, call the sub-scraper's init() method. | ||
| 81 | $self->init($serviceAdr, $native_query, $native_options); | ||
| 82 | return $self; | ||
| 83 | } | ||
| 84 | |||
| 85 | use WWW::Scraper::Request::WSDL; | ||
| 86 | sub init { | ||
| 87 | my ($self, $serviceAdr, $native_query, $native_options) = @_; | ||
| 88 | $scraperRequest->{'url'} = $serviceAdr if $serviceAdr; | ||
| 89 | |||
| 90 | $self->{'_service'} = SOAP::Lite -> service($scraperRequest->{'url'}); | ||
| 91 | |||
| 92 | $self->SetRequest( new WWW::Scraper::Request::WSDL($self, $native_query, $native_options) ) unless ( $self->GetRequest()); | ||
| 93 | return $self; | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | my $scraperFrame = | ||
| 98 | [ 'WSDL', | ||
| 99 | [ [ | ||
| 100 | ] ] | ||
| 101 | ]; | ||
| 102 | |||
| 103 | |||
| 104 | { | ||
| 105 | no warnings; | ||
| 106 | sub testParameters { | ||
| 107 | my ($self) = @_; | ||
| 108 | |||
| 109 | if ( ref $self ) { | ||
| 110 | $self->{'isTesting'} = 1; | ||
| 111 | } | ||
| 112 | |||
| 113 | return { | ||
| 114 | 'SKIP' => 'WSDL is still in a primitive experimental state.'#'WSDL test parameters have not yet been fixed' | ||
| 115 | ,'TODO' => 'WSDL is still in a primitive experimental state.' | ||
| 116 | ,'testNativeQuery' => 'MSFT' | ||
| 117 | ,'testNativeOptions' => { | ||
| 118 | 'getQuote' => 'MSFT' | ||
| 119 | } | ||
| 120 | ,'expectedOnePage' => 1 | ||
| 121 | ,'expectedMultiPage' => 1 | ||
| 122 | ,'expectedBogusPage' => 1 | ||
| 123 | }; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | # Access methods for the structural declarations of this Scraper engine. | ||
| 128 | sub scraperRequest { $scraperRequest } | ||
| 129 | sub scraperFrame { $_[0]->SUPER::scraperFrame($scraperFrame); } | ||
| 130 | |||
| 131 | 1; | ||
| 132 | |||
| 133 | |||
| 134 | __END__ |