zaczynam się bawić soap ale nie wiem do końca czy dobrze to ugryzłem napisałem taki kodzik :
<?php class TestWS extends SoapClient{ // Dołączenie pakietu NuSOAP private $WSDL = 'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL'; public function __construct(){ parent::SoapClient($this->WSDL); } // Utworzenie obiektu klienta SOAP public function WeatherReturn($city){ $query = new GetCityWeatherByZIPResponse(); $query->city = $city; // lub //return $this->WeatherReturn($query); } } class GetCityWeatherByZIPResponse{ public $city; } class WeatherReturn{ public $State; public $WeatherStationCit; public $Temperature; } $test_ws = new TestWS();; $city = 'warszawa'; $call = $test_ws->WeatherReturn($city); ?>
ale cały czas wywala mi błąd :
Kod
Fatal error: Uncaught SoapFault exception: [Client] Function ("WeatherReturn") is not a valid method for this service in E:\serwer\index.php:39 Stack trace: #0 E:\serwer\index.php(39): SoapClient->__soapCall('WeatherReturn', Array) #1 E:\serwer\index.php(72): TestWS->WeatherReturn('warszawa') #2 {main} thrown in E:\serwer\index.php on line 39
Kurczę już nie wiem jak to zrobić mógł by mi ktoś z obecnych pomóc zrobić nowe zapytanie ale do wsdl tego : http://www.webservicex.com/globalweather.asmx?WSDL albo na podstawie tego mojego kodu był bym wdzięczny jakby ktoś mi w tym pomógł
Przepraszam że post za postem ale nie chcę robić bałaganu , zrobiłem kod na ten drugi wsdl :
<?php class TestWS extends SoapClient{ private $WSDL = 'http://www.webservicex.com/globalweather.asmx?WSDL '; public function __construct(){ parent::SoapClient($this->WSDL); } /** * @return Pobierz_produkt_OUT * @param int $id_produktu */ public function GetWeather($city,$country){ $query = new GetWeatherSoapIn(); $query->CityName = $city; $query->CountryName = $country; // lub //return $this->Pobierz_produkt($query); }} $test_ws = new TestWS(); $city = 'warszawa'; $country = 'Poland'; $call = $test_ws->GetWeather($city,$country); //print_r("Pordukt o id ".$city." ma nazwę ".$call->nazwa." i kosztuje ".$call->cena." PLN"); ?>
i teraz mi taki błąd wychodzi , tak jakby w ogóle sie nie chciał połączyć :
Kod
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.webservicex.com/globalweather.asmx?WSDL ' : Premature end of data in tag html line 3 in E:\serwer\index.php:7 Stack trace: #0 E:\serwer\index.php(7): SoapClient->SoapClient('http://www.webs...') #1 E:\serwer\index.php(23): TestWS->__construct() #2 {main} thrown in E:\serwer\index.php on line 7
mam nadzieję , że ktoś pomoże
