The original problem reported that the Apache Axis Web service was claiming that it could not find the operation called 'getAirFareQuote.' However, upon inspecting the WSDL, one can see that it is indeed defined.
So I spent the next couple of minutes trying to figure out why it wouldn't recognize the operation, especially when I could call other operations documented in the same WSDL file. Weird.
In the end, it had to do with the way Axis was expecting its input parameters... I was misinterpreting an XML multiref that looked like this:
# <ns1:getAirFareQuote # soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" # xmlns:ns1="urn:SBGAirFareQuotes.sbg.travel.ws.dsdata.co.uk"> # <in0 href="#id0"/> # </ns1:getAirFareQuote> # <multiRef id="id0" soapenc:root="0" # soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" # xsi:type="ns2:AirFareQuoteRequest" # xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" # xmlns:ns2="urn:SBGAirFareQuotes.sbg.travel.ws.dsdata.co.uk"> # <outwardDate # xsi:type="xsd:dateTime">2003-04-28T08:00:00.000Z</outwardDate> # <returnDate # xsi:type="xsd:dateTime">2003-05-05T08:00:00.000Z</returnDate> # <originAirport xsi:type="xsd:string">LAX</originAirport> # <destinationAirport xsi:type="xsd:string">JFK</destinationAirport> # </multiRef>
Into something that looked like this:
# <ns1:getAirFareQuote # soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" # xmlns:ns1="urn:SBGAirFareQuotes.sbg.travel.ws.dsdata.co.uk"> # <outwardDate # xsi:type="xsd:dateTime">2003-04-28T08:00:00.000Z</outwardDate> # <returnDate # xsi:type="xsd:dateTime">2003-05-05T08:00:00.000Z</returnDate> # <originAirport xsi:type="xsd:string">LAX</originAirport> # <destinationAirport xsi:type="xsd:string">JFK</destinationAirport> # </ns1:getAirFareQuote>
When it should have looked like this:
# <ns1:getAirFareQuote # soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" # xmlns:ns1="urn:SBGAirFareQuotes.sbg.travel.ws.dsdata.co.uk"> # <in0> # <outwardDate # xsi:type="xsd:dateTime">2003-04-28T08:00:00.000Z</outwardDate> # <returnDate # xsi:type="xsd:dateTime">2003-05-05T08:00:00.000Z</returnDate> # <originAirport xsi:type="xsd:string">LAX</originAirport> # <destinationAirport xsi:type="xsd:string">JFK</destinationAirport> # </in0> # </ns1:getAirFareQuote>
Ok, ok, ok, that is a lot of XML... in the end, the following client was hacked together for SOAP::Lite to fetch airfares for a given set of times, destinations and origins:
#!/usr/bin/perl
#
# airfare.pl
# Author: breese at grandcentral.com
# Location of the WSDL file
my $WSDL
="http://wavendon.dsdata.co.uk:8080/axis/services/SBGGetAirFareQuote?wsdl";
my $NS = "urn:SBGAirFareQuotes.sbg.travel.ws.dsdata.co.uk";
my $HOST = "http://wavendon.dsdata.co.uk:8080/axis/services/SBGGetAirFareQuote";
use strict;
use SOAP::Lite +trace => qw (debug);
my $search = SOAP::Lite
->readable(1)
->xmlschema('http://www.w3.org/2001/XMLSchema')
->on_action( sub { return '""';} )
->proxy($HOST)
->uri($NS);
# CCYY-MM-DDThh:mm:ss
my $outwardDate = "2003-04-28T08:00:00.000Z";
my $returnDate = "2003-05-05T08:00:00.000Z";
my $origin = "LAX";
my $destination = "JFK";
my $method = SOAP::Data->name('getAirFareQuote')
->prefix('air')
->uri($NS);
my $params =
SOAP::Data
->type('air:AirFareQuoteRequest')
->name('in0' =>
\SOAP::Data->value(
SOAP::Data->name('outwardDate' => $outwardDate)->type('xsd:dateTime'),
SOAP::Data->name('returnDate' => $returnDate)->type('xsd:dateTime'),
SOAP::Data->name('originAirport' => $origin),
SOAP::Data->name('destinationAirport' => $destination)
));
my $results = $search->call($method => $params);
# Loop through the results
foreach my $result (@{$results->{'result'}}) {
print $result->{airlineName} . ": " . $result->{fare} . "\n";
}
1;
I don't think this
# Loop through the results
foreach my $result (@{$results->{'result'}}) {
print $result->{airlineName} . ": " . $result->{fare} . "\n";
}
can ever work. $results is a SOAP::SOM object which does not have 'result' key -- the only keys are
'_content' and '_current'
Posted by: | August 02, 2004 at 12:11 PM
Would you happen to know how to pass an array, e.g @myArray as an argument in SOAP::Lite. ?
I currently pass stings in the form:
SOAP::Data->name('modelOptions' => $modelOptions)->type(string)
but I would prefer to pass an array instead. Any suggestions?
Thanks in advance,
Gary Grubb
gary_grubb@agilent.com
Posted by: Gary Grubb | October 07, 2004 at 08:28 AM