Witam ,
Chciałbym pobrać dane o pogodzie do Bazy danych z tej witryny http://www.service-repository.com/service/overview/-2082028434 tylko nie wiem od czego zacząć ponieważ nigdy nie pracowałem z zapytaniami soap.
Z góry dziękuję i pozdrawiam
- Rejestracja:prawie 11 lat
- Ostatnio:prawie 11 lat
- Postów:9
0
- Rejestracja:prawie 11 lat
- Ostatnio:prawie 11 lat
- Postów:9
0
Dobra troche poczytałem i coś takie udało mi się skleić . tylko wywala mi błąd w tej linijce $test_ws = new TestWS();
<?php
// Dołączenie pakietu NuSOAP
require_once('lib/nusoap.php');
// Adres opisu usługi, z której będziemy korzystać
$wsdl_url = 'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL';
// Utworzenie obiektu klienta SOAP
$klient = new nusoap_client($wsdl_url, 'wsdl');
function WeatherReturn($city){
$query = new GetCityWeatherByZIPResponse();
$query->city = $city;
return $this->__soapCall('WeatherReturn', array($query));
// 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);
print_r("miasto: ".$city." ma temp ".$call->Temperature." i".$call->State);
?>
edytowany 1x, ostatnio: christod13
- Rejestracja:prawie 11 lat
- Ostatnio:prawie 11 lat
- Postów:9
0
Trochę to pozmieniałem i teraz mam coś takiego lecz mi błąd wyskakuje :
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
<?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;
return $this->__soapCall('WeatherReturn', array($query));
// 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);
print_r("miasto: ".$city." ma temp ".$call->Temperature." i".$call->State);
?>