diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php
index 99d89ed..d2213a0 100644
--- a/Controller/SoapWebServiceController.php
+++ b/Controller/SoapWebServiceController.php
@@ -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;
}
/**
diff --git a/Resources/config/routing/webservicecontroller.xml b/Resources/config/routing/webservicecontroller.xml
index 52a27f8..7d86541 100644
--- a/Resources/config/routing/webservicecontroller.xml
+++ b/Resources/config/routing/webservicecontroller.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- webservice.controller:handle
+ webservice.controller:call
POST
diff --git a/ServiceDefinition/Dumper/WsdlDumper.php b/ServiceDefinition/Dumper/WsdlDumper.php
index 3bccef6..ccc9a02 100644
--- a/ServiceDefinition/Dumper/WsdlDumper.php
+++ b/ServiceDefinition/Dumper/WsdlDumper.php
@@ -30,15 +30,17 @@ class WsdlDumper implements DumperInterface
{
Assert::thatArgumentNotNull('definition', $definition);
+ $options = array_merge(array('endpoint' => ''), $options);
+
$this->definition = $definition;
$wsdl = new Wsdl($definition->getName(), $definition->getNamespace());
$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();
}
diff --git a/WebServiceContext.php b/WebServiceContext.php
index 0f34b0d..ce764bb 100644
--- a/WebServiceContext.php
+++ b/WebServiceContext.php
@@ -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
*/
-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)
{
+ 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()
+ 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()