0

Kind of new to SOAP. Trying to get weather data from NOAA website. The first SOAP request shown below works, and returns the latitude and longitude. The second SOAP request doesn't work. I am obviously not sending the data correctly. Can anyone help? Thank you

<?php
    $wsdl = "http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl";

    $client = new SoapClient($wsdl,array("trace"=>1,"exceptions"=>0));

    $rs = $client->LatLonListZipCode(98011);
    echo('<pre>'.print_r($rs,1).'</pre>');

    $par=array('latitude'=>39.0000,'longitude'=>-77.0000,'product'=>'time-series','startTime'=>'2004-04-27T12:00','endTime'=>'2004-04-30T12:00','Unit'=>'e','weatherParameters'=>'maxt = TRUE');

    $rs = $client->NDFDgen($par);
    echo('<pre>'.print_r($rs,1).'</pre>');
?>
hakre
  • 193,403
  • 52
  • 435
  • 836
user1032531
  • 24,767
  • 68
  • 217
  • 387
  • In what way does the second request "not work?" Do you get an error message? – Matt Aug 30 '12 at 13:48
  • Yes, I get Notice: Array to string conversion in /var/www/html/testing/soap3.php on line 12, and then it returns a SoapFault Object. – user1032531 Aug 30 '12 at 13:52
  • What's on line 12? Is it `echo('
    '.print_r($rs,1).'
    ');`? I'm just making sure this is your actual code, and not just a snippet.
    – Matt Aug 30 '12 at 13:54
  • Line 12 is $rs = $client->NDFDgen($par). Playing around, and it looks like I don't want to pass it an array. – user1032531 Aug 30 '12 at 13:58
  • The following returns data: $rs = $client->NDFDgen(39.0000,-77.0000,'time-series','2012-08-31T12:00','2012-08-31T12:00','e','maxt = TRUE'); How would I have known that data should have been sent this way? – user1032531 Aug 30 '12 at 14:03
  • What does the WSDL definition say? – Matt Aug 30 '12 at 14:06
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16042/discussion-between-user1032531-and-matt) – user1032531 Aug 30 '12 at 14:07
  • Can't - office firewall blocks chat. – Matt Aug 30 '12 at 14:09
  • I don't understand the question. Is this what you mean? ? ? – user1032531 Aug 30 '12 at 14:14
  • Yes. I'm not an expert in dealing with SOAP requests, but I'm pretty sure that parameters are passed the same as you would pass them to any PHP function. – Matt Aug 30 '12 at 14:16
  • At "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl", an array is sent, and an object is returned. $values = $client->GetStockQuote(array("request"=>"NCR")); – user1032531 Aug 30 '12 at 14:22

1 Answers1

0

weatherParameters is supposed to be an Associative Array.

StackSlave
  • 10,613
  • 2
  • 18
  • 35