I'm working on my first "real" Symfony project which is a SOAP api. I have found the BeSimple SoapBundle and I want to add a few complex types to it that seem to be unsupported by the bundle. Amongst others I want to override the following function that is in the Dumper class:
protected function addComplexType(ComplexType $type)
{
}
It's located here: besimple/soap-wsdl/BeSimple/SoapWsdl/Dumper/Dumper.php
What I did is the following.
I created src/Webstuff/SoapBundle/SoapWsdl/Dumper/Dumper.php
That contains:
<?php
namespace Webstuff\SoapBundle\SoapWsdl\Dumper;
use BeSimple\SoapWsdl\Dumper as BaseDumper;
use BeSimple\SoapCommon\Definition\Definition;
class Dumper extends BaseDumper
{
public function __construct(Definition $definition, array $options = array())
{
echo 'CHECK';
exit;
}
}
?>
I have also added this to the WebstuffSoapBundle.php
public function getParent(){
return 'BeSimpleSoapBundle';
}
When visiting my wsdl path I would expect to see CHECK. But it's just loading the wsdl so this setup isn't working. I'm quite new to Symfony so I might be missing something obvious.
Hopefully someone can give me a push in the right direction! Thanks!
You need to: I. Extend the WebServiceContext
(located as: besimple/soap/src/BeSimple/SoapBundle/WebServiceContext.php ), so as to be able to use your dumper in " getWsdlFile
" method instead of the parent dumper.
Eg:
<?php
//Overriding WebServiceContext
namespace Webstuff\SoapBundle;
use Webstuff\SoapBundle\SoapWsdl\Dumper\Dumper;
use Symfony\Component\Config\ConfigCache;
class WebServiceContext extends \BeSimple\SoapBundle\WebServiceContext
{
private $options;
public function __construct($loader, $converters, $options)
{
$this->options = $options;
return parent::__construct($loader,$converters,$options);
}
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()) {
$definition = $this->getServiceDefinition();
if ($endpoint) {
$definition->setOption('location', $endpoint);
}
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
$cache->write($dumper->dump());
}
return (string) $cache;
}
}
?php>
II. Set " besimple.soap.context.class
" parameter in config.yml
to refer to your class that extends WebServiceContext
.
Eg:
# app/config/config.yml
parameters:
besimple.soap.context.class: "Webstuff\SoapBundle\WebServiceContext"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.