Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 3 support #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"ext-soap": "*",
"ext-curl": "*",
"ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~2.6",
"symfony/twig-bundle": "~2.6",
"symfony/framework-bundle": "^2.7 || ^3.0",
"symfony/twig-bundle": "^2.7 || ^3.0",
"zendframework/zend-mime": "2.1.*"
},
"replace": {
Expand Down
17 changes: 9 additions & 8 deletions src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
use BeSimple\SoapBundle\Soap\SoapRequest;
use BeSimple\SoapBundle\Soap\SoapResponse;
use BeSimple\SoapServer\SoapServerBuilder;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
* @author Christian Kerl <[email protected]>
* @author Francis Besset <[email protected]>
*/
class SoapWebServiceController extends ContainerAware
class SoapWebServiceController extends Controller
{
/**
* @var \SoapServer
Expand Down Expand Up @@ -58,13 +59,14 @@ class SoapWebServiceController extends ContainerAware
/**
* @return \BeSimple\SoapBundle\Soap\SoapResponse
*/
public function callAction($webservice)
public function callAction(Request $request, $webservice)
{
$webServiceContext = $this->getWebServiceContext($webservice);

$this->serviceBinder = $webServiceContext->getServiceBinder();

$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
$this->soapRequest = SoapRequest::createFromHttpRequest($request);

$this->soapServer = $webServiceContext
->getServerBuilder()
->withSoapVersion11()
Expand All @@ -85,17 +87,16 @@ public function callAction($webservice)
/**
* @return Symfony\Component\HttpFoundation\Response
*/
public function definitionAction($webservice)
public function definitionAction(Request $request, $webservice)
{
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
$this->container->get('router')->generate(
'_webservice_call',
array('webservice' => $webservice),
true
UrlGeneratorInterface::ABSOLUTE_URL
)
));

$request = $this->container->get('request');
$query = $request->query;
if ($query->has('wsdl') || $query->has('WSDL')) {
$request->setRequestFormat('wsdl');
Expand Down
19 changes: 0 additions & 19 deletions src/BeSimple/SoapBundle/Converter/TypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace BeSimple\SoapBundle\Converter;

use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\Util\Assert;

/**
Expand Down Expand Up @@ -45,22 +44,4 @@ public function getXmlTypeMapping($phpType)
{
return isset($this->defaultTypeMap[$phpType]) ? $this->defaultTypeMap[$phpType] : null;
}

public function fixTypeInformation(ServiceDefinition $definition)
{
foreach($definition->getAllTypes() as $type) {
$phpType = $type->getPhpType();
$xmlType = $type->getXmlType();

if (null === $phpType) {
throw new \InvalidArgumentException();
}

if (null === $xmlType) {
$xmlType = $this->getXmlTypeMapping($phpType);
}

$type->setXmlType($xmlType);
}
}
}
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/Handler/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use BeSimple\SoapServer\Exception\ReceiverSoapFault;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException;

/**
* @author Francis Besset <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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" path="/{webservice}" methods="POST">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
<default key="_format">xml</default>
<requirement key="_method">POST</requirement>
</route>

<route id="_webservice_definition" pattern="/{webservice}">
<route id="_webservice_definition" path="/{webservice}" methods="GET">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
<default key="_format">xml</default>
<requirement key="_method">GET</requirement>
</route>
</routes>
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/ServiceBinding/ServiceBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class ServiceBinder
{
/**
* @var \BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition
* @var \BeSimple\SoapBundle\ServiceDefinition\Definition
*/
private $definition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(Reader $reader, TypeRepository $typeRepository)
* @param string $class A class name
* @param string $type The resource type
*
* @return \BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition A ServiceDefinition instance
* @return \BeSimple\SoapBundle\ServiceDefinition\Definition A Definition instance
*
* @throws \InvalidArgumentException When route can't be parsed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BeSimple\SoapBundle\ServiceDefinition\Loader;

use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\ServiceDefinition\Definition;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\FileLoader;
Expand Down Expand Up @@ -52,7 +52,7 @@ public function __construct(FileLocator $locator, AnnotationClassLoader $loader,
* @param string $file A PHP file path
* @param string $type The resource type
*
* @return ServiceDefinition A ServiceDefinition instance
* @return Definition A Definition instance
*
* @throws \InvalidArgumentException When the file does not exist
*/
Expand Down
6 changes: 3 additions & 3 deletions src/BeSimple/SoapBundle/WebServiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getServiceDefinition()
if (null === $this->serviceDefinition) {
$cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
if ($cache->isFresh()) {
$this->serviceDefinition = include (string) $cache;
$this->serviceDefinition = include $cache->getPath();
} else {
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) {
throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
Expand All @@ -71,7 +71,7 @@ public function getWsdlFile($endpoint = null)
$file = sprintf ('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$cache = new ConfigCache($file, $this->options['debug']);

if(!$cache->isFresh()) {
if (!$cache->isFresh()) {
$definition = $this->getServiceDefinition();

if ($endpoint) {
Expand All @@ -82,7 +82,7 @@ public function getWsdlFile($endpoint = null)
$cache->write($dumper->dump());
}

return (string) $cache;
return $cache->getPath();
}

public function getServiceBinder()
Expand Down