From 1e82d7fdd7003041d92b806186391fbaf36a21f4 Mon Sep 17 00:00:00 2001 From: Rekky Date: Tue, 26 Nov 2013 11:39:07 +0400 Subject: [PATCH] Fix WSDL schema stylesheet including --- .../SoapBundle/Resources/config/webservice.xml | 2 ++ src/BeSimple/SoapBundle/WebServiceContext.php | 2 +- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 6b38d56..343885c 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -44,6 +44,7 @@ %besimple.soap.binder.request_header.rpcliteral.class% %besimple.soap.binder.request.rpcliteral.class% %besimple.soap.binder.response.rpcliteral.class% + %besimple.soap.definition.dumper.options.stylesheet% @@ -58,6 +59,7 @@ %besimple.soap.binder.request_header.documentwrapped.class% %besimple.soap.binder.request.documentwrapped.class% %besimple.soap.binder.response.documentwrapped.class% + %besimple.soap.definition.dumper.options.stylesheet% diff --git a/src/BeSimple/SoapBundle/WebServiceContext.php b/src/BeSimple/SoapBundle/WebServiceContext.php index 28316f6..dce81a7 100644 --- a/src/BeSimple/SoapBundle/WebServiceContext.php +++ b/src/BeSimple/SoapBundle/WebServiceContext.php @@ -78,7 +78,7 @@ class WebServiceContext $definition->setOption('location', $endpoint); } - $dumper = new Dumper($definition); + $dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet'])); $cache->write($dumper->dump()); } diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index bcce154..ac2483c 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -69,6 +69,7 @@ class Dumper 'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12', 'version11_name' => $this->definition->getName(), 'version12_name' => $this->definition->getName().'12', + 'stylesheet' => null, ); $invalid = array(); @@ -123,6 +124,8 @@ class Dumper $this->document->formatOutput = true; + $this->addStylesheet(); + return $this->document->saveXML(); } @@ -297,6 +300,15 @@ class Dumper return $operation; } + protected function addStylesheet() + { + if ($this->options['stylesheet']) { + $stylesheet = $this->document->createProcessingInstruction('xml-stylesheet', sprintf('type="text/xsl" href="%s"', $this->options['stylesheet'])); + + $this->document->insertBefore($stylesheet, $this->document->documentElement); + } + } + protected function getVersion($version) { if (\SOAP_1_2 === $version) {