wsdl definition can now be retrieved; aligned controller method and route naming;
This commit is contained in:
parent
a4d69aedbc
commit
fa07646e3a
|
@ -77,7 +77,7 @@ class SoapWebServiceController extends ContainerAware
|
||||||
return $this->soapResponse;
|
return $this->soapResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle($webservice)
|
public function call($webservice)
|
||||||
{
|
{
|
||||||
$webServiceContext = $this->container->get('webservice.context.' . $webservice);
|
$webServiceContext = $this->container->get('webservice.context.' . $webservice);
|
||||||
|
|
||||||
|
@ -106,16 +106,19 @@ class SoapWebServiceController extends ContainerAware
|
||||||
|
|
||||||
if($request->query->has('WSDL'))
|
if($request->query->has('WSDL'))
|
||||||
{
|
{
|
||||||
$response = new Response(file_get_contents($webServiceContext->getWsdlFile()));
|
$endpoint = $this->container->get('router')->generate('_webservice_call', array('webservice' => $webservice), true);
|
||||||
$response->headers->set('Content-Type', 'application/wsdl+xml');
|
|
||||||
|
|
||||||
return $response;
|
$response = new Response($webServiceContext->getWsdlFileContent($endpoint));
|
||||||
|
$response->headers->set('Content-Type', 'text/plain');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$response = new Response('woho');
|
||||||
// dump pretty definition
|
// dump pretty definition
|
||||||
// return $this->container->get('templating')->renderView('');
|
// return $this->container->get('templating')->renderView('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
<route id="_webservice_call" pattern="/{webservice}">
|
<route id="_webservice_call" pattern="/{webservice}">
|
||||||
<default key="_controller">webservice.controller:handle</default>
|
<default key="_controller">webservice.controller:call</default>
|
||||||
<requirement key="_method">POST</requirement>
|
<requirement key="_method">POST</requirement>
|
||||||
</route>
|
</route>
|
||||||
<route id="_webservice_definition" pattern="/{webservice}">
|
<route id="_webservice_definition" pattern="/{webservice}">
|
||||||
|
|
|
@ -30,6 +30,8 @@ class WsdlDumper implements DumperInterface
|
||||||
{
|
{
|
||||||
Assert::thatArgumentNotNull('definition', $definition);
|
Assert::thatArgumentNotNull('definition', $definition);
|
||||||
|
|
||||||
|
$options = array_merge(array('endpoint' => ''), $options);
|
||||||
|
|
||||||
$this->definition = $definition;
|
$this->definition = $definition;
|
||||||
|
|
||||||
$wsdl = new Wsdl($definition->getName(), $definition->getNamespace());
|
$wsdl = new Wsdl($definition->getName(), $definition->getNamespace());
|
||||||
|
@ -37,8 +39,8 @@ class WsdlDumper implements DumperInterface
|
||||||
$port = $wsdl->addPortType($this->getPortTypeName());
|
$port = $wsdl->addPortType($this->getPortTypeName());
|
||||||
$binding = $wsdl->addBinding($this->getBindingName(), $this->getPortTypeName());
|
$binding = $wsdl->addBinding($this->getBindingName(), $this->getPortTypeName());
|
||||||
|
|
||||||
$wsdl->addSoapBinding($binding, 'document');
|
$wsdl->addSoapBinding($binding, 'rpc');
|
||||||
$wsdl->addService($this->getServiceName(), $this->getPortTypeName(), $this->getBindingName(), '');
|
$wsdl->addService($this->getServiceName(), $this->getPortTypeName(), $this->getBindingName(), $options['endpoint']);
|
||||||
|
|
||||||
foreach($definition->getMethods() as $method)
|
foreach($definition->getMethods() as $method)
|
||||||
{
|
{
|
||||||
|
@ -77,6 +79,8 @@ class WsdlDumper implements DumperInterface
|
||||||
|
|
||||||
$this->definition = null;
|
$this->definition = null;
|
||||||
|
|
||||||
|
$wsdl->toDomDocument()->formatOutput = true;
|
||||||
|
|
||||||
return $wsdl->toXml();
|
return $wsdl->toXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,21 +10,21 @@
|
||||||
|
|
||||||
namespace Bundle\WebServiceBundle;
|
namespace Bundle\WebServiceBundle;
|
||||||
|
|
||||||
|
|
||||||
|
use Symfony\Component\Config\ConfigCache;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
|
||||||
|
use Bundle\WebServiceBundle\Converter\ConverterRepository;
|
||||||
|
use Bundle\WebServiceBundle\ServiceBinding\ServiceBinder;
|
||||||
|
use Bundle\WebServiceBundle\ServiceBinding\MessageBinderInterface;
|
||||||
|
use Bundle\WebServiceBundle\ServiceDefinition\Dumper\DumperInterface;
|
||||||
|
use Bundle\WebServiceBundle\Soap\SoapServerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebServiceContext.
|
* WebServiceContext.
|
||||||
*
|
*
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
*/
|
*/
|
||||||
use Bundle\WebServiceBundle\ServiceDefinition\Dumper\DumperInterface;
|
|
||||||
|
|
||||||
use Bundle\WebServiceBundle\ServiceBinding\MessageBinderInterface;
|
|
||||||
|
|
||||||
use Bundle\WebServiceBundle\Converter\ConverterRepository;
|
|
||||||
|
|
||||||
use Bundle\WebServiceBundle\ServiceBinding\ServiceBinder;
|
|
||||||
|
|
||||||
use Bundle\WebServiceBundle\Soap\SoapServerFactory;
|
|
||||||
|
|
||||||
class WebServiceContext
|
class WebServiceContext
|
||||||
{
|
{
|
||||||
private $converterRepository;
|
private $converterRepository;
|
||||||
|
@ -56,15 +56,36 @@ class WebServiceContext
|
||||||
{
|
{
|
||||||
if($this->serviceDefinition === null)
|
if($this->serviceDefinition === null)
|
||||||
{
|
{
|
||||||
|
if(!$this->serviceDefinitionLoader->supports($this->options['resource'], $this->options['resource_type']))
|
||||||
}
|
|
||||||
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWsdlFile()
|
|
||||||
{
|
{
|
||||||
;
|
throw new \LogicException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->serviceDefinition = $this->serviceDefinitionLoader->load($this->options['resource'], $this->options['resource_type']);
|
||||||
|
$this->serviceDefinition->setName($this->options['name']);
|
||||||
|
$this->serviceDefinition->setNamespace($this->options['namespace']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->serviceDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWsdlFile($endpoint = null)
|
||||||
|
{
|
||||||
|
$id = $endpoint !== null ? '.' . md5($endpoint) : '';
|
||||||
|
$file = sprintf('%s/%s.wsdl', $this->options['cache_dir'], $this->options['name'] . $id);
|
||||||
|
$cache = new ConfigCache($file, true);
|
||||||
|
|
||||||
|
if(!$cache->isFresh())
|
||||||
|
{
|
||||||
|
$cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), array('endpoint' => $endpoint)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWsdlFileContent($endpoint = null)
|
||||||
|
{
|
||||||
|
return file_get_contents($this->getWsdlFile($endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getServiceBinder()
|
public function getServiceBinder()
|
||||||
|
|
Loading…
Reference in New Issue