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;
|
||||
}
|
||||
|
||||
public function handle($webservice)
|
||||
public function call($webservice)
|
||||
{
|
||||
$webServiceContext = $this->container->get('webservice.context.' . $webservice);
|
||||
|
||||
|
@ -106,16 +106,19 @@ class SoapWebServiceController extends ContainerAware
|
|||
|
||||
if($request->query->has('WSDL'))
|
||||
{
|
||||
$response = new Response(file_get_contents($webServiceContext->getWsdlFile()));
|
||||
$response->headers->set('Content-Type', 'application/wsdl+xml');
|
||||
$endpoint = $this->container->get('router')->generate('_webservice_call', array('webservice' => $webservice), true);
|
||||
|
||||
return $response;
|
||||
$response = new Response($webServiceContext->getWsdlFileContent($endpoint));
|
||||
$response->headers->set('Content-Type', 'text/plain');
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = new Response('woho');
|
||||
// dump pretty definition
|
||||
// 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">
|
||||
|
||||
<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>
|
||||
</route>
|
||||
<route id="_webservice_definition" pattern="/{webservice}">
|
||||
|
|
|
@ -30,6 +30,8 @@ class WsdlDumper implements DumperInterface
|
|||
{
|
||||
Assert::thatArgumentNotNull('definition', $definition);
|
||||
|
||||
$options = array_merge(array('endpoint' => ''), $options);
|
||||
|
||||
$this->definition = $definition;
|
||||
|
||||
$wsdl = new Wsdl($definition->getName(), $definition->getNamespace());
|
||||
|
@ -37,8 +39,8 @@ class WsdlDumper implements DumperInterface
|
|||
$port = $wsdl->addPortType($this->getPortTypeName());
|
||||
$binding = $wsdl->addBinding($this->getBindingName(), $this->getPortTypeName());
|
||||
|
||||
$wsdl->addSoapBinding($binding, 'document');
|
||||
$wsdl->addService($this->getServiceName(), $this->getPortTypeName(), $this->getBindingName(), '');
|
||||
$wsdl->addSoapBinding($binding, 'rpc');
|
||||
$wsdl->addService($this->getServiceName(), $this->getPortTypeName(), $this->getBindingName(), $options['endpoint']);
|
||||
|
||||
foreach($definition->getMethods() as $method)
|
||||
{
|
||||
|
@ -77,6 +79,8 @@ class WsdlDumper implements DumperInterface
|
|||
|
||||
$this->definition = null;
|
||||
|
||||
$wsdl->toDomDocument()->formatOutput = true;
|
||||
|
||||
return $wsdl->toXml();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,21 +10,21 @@
|
|||
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
{
|
||||
private $converterRepository;
|
||||
|
@ -56,15 +56,36 @@ class WebServiceContext
|
|||
{
|
||||
if($this->serviceDefinition === null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public function getWsdlFile()
|
||||
if(!$this->serviceDefinitionLoader->supports($this->options['resource'], $this->options['resource_type']))
|
||||
{
|
||||
;
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue