<?php # HelloClient.php # Copyright (c) 2005 by Dr. Herong Yang # error_reporting(E_ALL); ini_set('display_errors', True); ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache $client = new SoapClient("catalog.wsdl"); $return = $client->getItemCount('12345'); print_r($return); $return = $client->sayHello('Hello World!'); echo $return;
* * @param string|object $destination * @param object $sourceObject * @return object */ function cast($destination, $sourceObject) { if (is_string($destination)) { $destination = new $destination(); } $sourceReflection = new ReflectionObject($sourceObject); $destinationReflection = new ReflectionObject($destination); $sourceProperties = $sourceReflection->getProperties(); foreach ($sourceProperties as $sourceProperty) { $sourceProperty->setAccessible(true); $name = $sourceProperty->getName(); $value = $sourceProperty->getValue($sourceObject); if ($destinationReflection->hasProperty($name)) { $propDest = $destinationReflection->getProperty($name); $propDest->setAccessible(true); $propDest->setValue($destination, $value); } else { $destination->{$name} = $value; } } return $destination; } $res = $client->sayHello("max"); var_dump($res); $res = $client->sayVelo("max"); var_dump(cast(new Example(), $res)->getName());
<?php // Создание SOAP-клиента по WSDL-документу $wsdl = 'server.wsdl'; $client = new SoapClient($wsdl); // Поcылка SOAP-запроса и получение результата header('Content-type: text/html; charset=utf-8'); echo $client->getTime(), '<br>'; echo $client->sayHello('Вася'), '<br>';