Skip to content

Commit

Permalink
soap
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed May 11, 2011
1 parent c5a3d33 commit 127a01c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Empty file added soap/development.log
Empty file.
58 changes: 58 additions & 0 deletions soap/index.php
@@ -0,0 +1,58 @@
<?php

require_once __DIR__.'/silex.phar';

use Symfony\Component\HttpFoundation\Response;

$app = new Silex\Application();

$app->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();
3 changes: 3 additions & 0 deletions 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

0 comments on commit 127a01c

Please sign in to comment.