user354134
user354134

Reputation:

Trivial port of SOAP ruby code to Perl SOAP::Lite fails

This ruby code works great:

require 'soap/wsdlDriver'
wsdl_url = 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl'
proxy = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
print proxy.NDFDgen(35.05,-106.65,"glance","2010-11-20T00:00:00","2010-11-20T07:00:00","temp")

This Perl code returns an empty string:

use SOAP::Lite; 
$client = SOAP::Lite->new(proxy => "http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"); 
$som = $client->call("NDFDgen", 35.05,-106.65,"glance","2010-11-20T00:00:00","2010-11-20T07:00:00","temp"); 
die $som->fault->{ faultstring } if ($som->fault); 
print $som->result, "\n"; 

Pray tell why? (the Perl code is almost a direct copy/paste from "perldoc SOAP::Lite").

Upvotes: 0

Views: 503

Answers (2)

Secesh
Secesh

Reputation: 385

The ruby code you reference does not work as expected -- it will return more than just the 'temp' forecast. See http://g.chasefox.net/clearos/ruby/noaa-nws-ndfd

And regarding the perl code, I suggest reviewing NOAA's example. They have provided examples in a few languages, one of which is perl, which utilizes SOAP::Lite. See: http://www.weather.gov/forecasts/xml/sample_products/ndfdXML.tar

print SOAP::Lite
      ->proxy('http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php')
      ->uri('http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl')
      ->NDFDgen(SOAP::Data->name("latitude" => 35.05),
                SOAP::Data->name("longitude" => -106.65),
                SOAP::Data->name("product" => "glance"),
                SOAP::Data->name("startTime" => "2011-05-08T00:00:00"),
                SOAP::Data->name("endTime" => "2011-05-09T00:00:00"),
                SOAP::Data->name("weatherParameters" => 'blah') )
       ->result

Upvotes: 0

Ether
Ether

Reputation: 53986

SOAP::Lite is notoriously hard to use - you may find XML::Compile::SOAP works better for you.

Upvotes: 1

Related Questions