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

Override Builder #92

Open
dionsnoeijen opened this issue Sep 17, 2014 · 1 comment
Open

Override Builder #92

dionsnoeijen opened this issue Sep 17, 2014 · 1 comment

Comments

@dionsnoeijen
Copy link

Hi all,

I'm trying to override this function:

    protected function addComplexType(ComplexType $type)
    {
    $complexType = $this->document->createElement(static::XSD_NS.':complexType');
    $complexType->setAttribute('name', $type->getXmlType());

    $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all'));
    $complexType->appendChild($all);

    foreach ($type->all() as $child) {
        $childType = $this->definition->getTypeRepository()->getType($child->getType());

        $element = $this->document->createElement(static::XSD_NS.':element');
        $element->setAttribute('name', $child->getName());

        if ($childType instanceof ComplexType) {
            $name = $childType->getXmlType();
            if ($childType instanceof ArrayOfType) {
                $name = $childType->getName();
            }

            $element->setAttribute('type', static::TYPES_NS.':'.$name);
        } else {
            $element->setAttribute('type', $childType);
        }

        if ($child->isNillable()) {
            $element->setAttribute('nillable', 'true');
        }

        if ($type instanceof ArrayOfType) {
            $element->setAttribute('minOccurs', 0);
            $element->setAttribute('maxOccurs', 'unbounded');
        }

        $all->appendChild($element);
    }

    $this->domSchema->appendChild($complexType);
}

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. Hopefully someone can give me a push in the right direction! Thanks!

@salmagomaa
Copy link

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.

E.g.: //Overriding WebServiceContext

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; } ``` } ?>

II. Set "besimple.soap.context.class" parameter in config.yml to refer to your class that extends WebServiceContext.

E.g.: # app/config/config.yml
parameters:
besimple.soap.context.class: "Webstuff\SoapBundle\WebServiceContext"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants