Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
[Info]
SOAP Example
soap_server.php
<?php
class Nina {
function getWeather($type,$ort) {
$stations = new StdClass;
$station1 = new StdClass;
$station2 = new StdClass;
$station1->anlage = 'Hohe Warte';
$station1->temperatur= '12 Grad';
$station2->anlage = 'Pfaender';
$station2->temperatur= '50 Grad';
$stations->station = array($station1,$station2);
return $stations;
}
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$test = new Nina;
header('content-type: text/plain');
print_r($test->getWeather('a','b'));
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
ini_set("soap.wsdl_cache_enabled","0");
$server = new SoapServer('blubb.wsdl');
$server->setClass('Nina');
$server->handle();
exit;
}
?>
soap_client.php
<?php
ini_set("soap.wsdl_cache_enabled","0");
$client = new SoapClient('blubb.wsdl',array('trace'=>1));
$result = $client->getWeather('c','d');
header('content-type: text/plain');
print_r($result);
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$doc->loadXML($client->__getLastRequest());
print $doc->saveXML();
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$doc->loadXML($client->__getLastResponse());
print $doc->saveXML();
?>
Letzte Änderung: 23.04.2015, 12:59 | 130 Worte