diff --git a/soap/development.log b/soap/development.log new file mode 100644 index 0000000..e69de29 diff --git a/soap/index.php b/soap/index.php new file mode 100644 index 0000000..b8c8a25 --- /dev/null +++ b/soap/index.php @@ -0,0 +1,58 @@ +register(new Silex\Extension\MonologExtension(), array( + 'monolog.logfile' => __DIR__.'/development.log', + 'monolog.class_path' => __DIR__.'/vendor/monolog/src', +)); + +$app['autoloader']->registerNamespace('Zend', __DIR__.'/vendor/zf2/library'); + +class SoapService +{ + /** + * Returns a hello world + * + * @param string $name + * @return string the hello world + */ + public function hello($name) + { + return "Hello $name!"; + } +} + +$app->before(function () use ($app) { + $app['base_url'] = $app['request']->getScheme().'://'.$app['request']->getHttpHost().$app['request']->getBaseUrl(); + + ini_set("soap.wsdl_cache_enabled", "0"); +}); + +$app->match('/', function () use ($app) { + $server = new Zend\Soap\Server($app['base_url'].'/wsdl'); + $server->setObject(new SoapService()); + $server->setReturnResponse(true); + $response = $server->handle($app['request']->getContent()); + return $response; +}); + +$app->get('/wsdl', function () use ($app) { + $autodiscover = new Zend\Soap\AutoDiscover(); + $autodiscover->setClass('SoapService'); + $autodiscover->setUri($app['base_url']); + $wsdl = $autodiscover->toXml(); + + return new Response($wsdl, 200, array('Content-Type' => 'application/xml')); +}); + +$app->get('/client', function () use ($app) { + $client = new Zend\Soap\Client($app['base_url'].'/wsdl'); + return $client->hello("igor"); +}); + +$app->run(); diff --git a/soap/vendors.sh b/soap/vendors.sh new file mode 100755 index 0000000..0e5eb98 --- /dev/null +++ b/soap/vendors.sh @@ -0,0 +1,3 @@ +#!/bin/sh +git clone https://github.com/Seldaek/monolog.git vendor/monolog +git clone https://github.com/zendframework/zf2.git vendor/zf2