Page 1 of 1
question about w2dl2php and calling a web service
Posted: Wed Aug 01, 2007 6:34 pm
by yacahuma
I am playing with soap client. I downloaded and install pear and wsdl2php. I was trying to use the web service from
http://www.weather.gov/xml/#use_it
using wsdl2php I got a new file with 2 classes and some other stuff
The problem is that when I call the class
Code: Select all
$test = new ndfdXML();
$test->NDFDgenByDay(38.99,-77.99,'2007-08-01',7,'24 hourly');
When I run this I get this error
C:\php\PEAR>php -f ndfdXML.php
Catchable fatal error: Argument 3 passed to ndfdXML::NDFDgenByDay() must be an i
nstance of date, string given, called in C:\php\PEAR\ndfdXML.php on line 122 and
defined in C:\php\PEAR\ndfdXML.php on line 110
If you look at there example, thbey submit a form and this is what you get
http://www.weather.gov/forecasts/xml/SO ... mit=Submit
It is like is expecting an object instead of a string
Posted: Wed Aug 01, 2007 9:21 pm
by Begby
Was one of the classes generated by wsdl2php a date class by any chance?
HERE IT GOES FULL CODE
Posted: Wed Aug 01, 2007 11:01 pm
by yacahuma
FULL CODE. I dont see a date class anywhere
Code: Select all
<?php
class formatType {
const value_24_hourly = '24 hourly';
const value_12_hourly = '12 hourly';
}
class productType {
const time_series = 'time-series';
const glance = 'glance';
}
class weatherParametersType {
public $maxt; // boolean
public $mint; // boolean
public $temp; // boolean
public $dew; // boolean
public $pop12; // boolean
public $qpf; // boolean
public $sky; // boolean
public $snow; // boolean
public $wspd; // boolean
public $wdir; // boolean
public $wx; // boolean
public $waveh; // boolean
public $icons; // boolean
public $rh; // boolean
public $appt; // boolean
public $incw34; // boolean
public $incw50; // boolean
public $incw64; // boolean
public $cumw34; // boolean
public $cumw50; // boolean
public $cumw64; // boolean
public $wgust; // boolean
public $conhazo; // boolean
public $ptornado; // boolean
public $phail; // boolean
public $ptstmwinds; // boolean
public $pxtornado; // boolean
public $pxhail; // boolean
public $pxtstmwinds; // boolean
public $ptotsvrtstm; // boolean
public $pxtotsvrtstm; // boolean
}
/**
* ndfdXML class
*
* The service has two exposed functions, NDFDgen and NDFDgenByDay. For the NDFDgen function,
* the client needs to provide a latitude and longitude pair and the product type. The client
* also needs to provide the start and end time of the period that it wants data for. For
* the time-series product, the client needs to provide an array of boolean values corresponding
* to which weather values should appear in the time series product. For the NDFDgenByDay
* function, the client needs to provide a latitude and longitude pair, the date it wants to
* start retrieving data for and the number of days worth of data. The client also needs to
* provide the format that is desired.
*
* @author {author}
* @copyright {copyright}
* @package {package}
*/
class ndfdXML extends SoapClient {
private static $classmap = array(
'formatType' => 'formatType',
'productType' => 'productType',
'weatherParametersType' => 'weatherParametersType',
);
public function ndfdXML($wsdl = "http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl", $options = array()) {
foreach(self::$classmap as $key => $value) {
if(!isset($options['classmap'][$key])) {
$options['classmap'][$key] = $value;
}
}
parent::__construct($wsdl, $options);
}
/**
* Returns National Weather Service digital weather forecast data
*
* @param decimal $latitude
* @param decimal $longitude
* @param productType $product
* @param dateTime $startTime
* @param dateTime $endTime
* @param weatherParametersType $weatherParameters
* @return string
*/
public function NDFDgen($latitude, $longitude, productType $product, $startTime, $endTime, weatherParametersType $weatherParameters) {
return $this->__soapCall('NDFDgen', array($latitude, $longitude, $product, $startTime, $endTime, $weatherParameters), array(
'uri' => 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl',
'soapaction' => ''
)
);
}
/**
* Returns National Weather Service digital weather forecast data summarized over either
* 24- or 12-hourly periods
*
* @param decimal $latitude
* @param decimal $longitude
* @param date $startDate
* @param integer $numDays
* @param formatType $format
* @return string
*/
public function NDFDgenByDay($latitude, $longitude, date $startDate, integer $numDays, formatType $format) {
return $this->__soapCall('NDFDgenByDay', array($latitude, $longitude, $startDate, $numDays, $format), array(
'uri' => 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl',
'soapaction' => ''
)
);
}
}
$test = new ndfdXML();
$test->NDFDgenByDay(38.99,-77.99,'2007-08-01',7,'24 hourly');
?>