diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index 90eede1..1816377 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -53,6 +53,7 @@ class SoapWebServiceController extends ContainerAware $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); $this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->soapResponse); + $this->soapServer->setObject($this); ob_start(); diff --git a/Resources/config/loaders.xml b/Resources/config/loaders.xml index 51c4e10..4347f94 100644 --- a/Resources/config/loaders.xml +++ b/Resources/config/loaders.xml @@ -10,6 +10,7 @@ BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationDirectoryLoader BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationFileLoader BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationClassLoader + BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader @@ -29,6 +30,10 @@ + + + + diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index 5dc9f8f..3fb9b7e 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -50,7 +50,9 @@ - + + + diff --git a/ServiceBinding/MessageBinderInterface.php b/ServiceBinding/MessageBinderInterface.php index f355f76..542112b 100644 --- a/ServiceBinding/MessageBinderInterface.php +++ b/ServiceBinding/MessageBinderInterface.php @@ -20,5 +20,5 @@ interface MessageBinderInterface * * @return mixed */ - function processMessage(Method $messageDefinition, $message); + function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()); } \ No newline at end of file diff --git a/ServiceBinding/RpcLiteralRequestMessageBinder.php b/ServiceBinding/RpcLiteralRequestMessageBinder.php index 12c8e78..c349b73 100644 --- a/ServiceBinding/RpcLiteralRequestMessageBinder.php +++ b/ServiceBinding/RpcLiteralRequestMessageBinder.php @@ -11,16 +11,42 @@ namespace BeSimple\SoapBundle\ServiceBinding; use BeSimple\SoapBundle\ServiceDefinition\Method; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType; class RpcLiteralRequestMessageBinder implements MessageBinderInterface { - public function processMessage(Method $messageDefinition, $message) + public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()) { $result = array(); $i = 0; foreach($messageDefinition->getArguments() as $argument) { if (isset($message[$i])) { + if (preg_match('/^([^\[]+)\[\]$/', $argument->getType()->getPhpType(), $match)) { + $isArray = true; + $type = $match[1]; + } else { + $isArray = false; + $type = $argument->getType()->getPhpType(); + } + + if (isset($definitionComplexTypes[$type])) { + if ($isArray) { + $array = array(); + + foreach ($message[$i]->item as $complexType) { + $array[] = $this->getInstanceOfType($type, $complexType, $definitionComplexTypes); + } + + $message[$i] = $array; + } else { + $message[$i] = $this->getInstanceOfType($type, $message[$i], $definitionComplexTypes); + } + } elseif ($isArray) { + $message[$i] = $message[$i]->item; + } + $result[$argument->getName()] = $message[$i]; } @@ -29,4 +55,38 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface return $result; } + + private function getInstanceOfType($type, $message, array $definitionComplexTypes) + { + $typeClass = $type; + $instanceType = new $typeClass(); + + foreach ($definitionComplexTypes[$type] as $type) { + if ($type instanceof PropertyComplexType) { + if (isset($definitionComplexTypes[$type->getValue()])) { + $value = $this->getInstanceOfType($type->getValue(), $message->{$type->getName()}, $definitionComplexTypes); + } else { + $value = $message->{$type->getName()}; + } + + $instanceType->{$type->getOriginalName()} = $value; + } elseif ($type instanceof MethodComplexType) { + if (!$type->getSetter()) { + throw new \LogicException(); + } + + if (isset($definitionComplexTypes[$type->getValue()])) { + $value = $this->getInstanceOfType($type->getValue(), $message->{$type->getName()}, $definitionComplexTypes); + } else { + $value = $message->{$type->getName()}; + } + + $instanceType->{$type->getSetter()}($value); + } else { + throw new \InvalidArgumentException(); + } + } + + return $instanceType; + } } \ No newline at end of file diff --git a/ServiceBinding/RpcLiteralResponseMessageBinder.php b/ServiceBinding/RpcLiteralResponseMessageBinder.php index e4b4aa2..29b7d0e 100644 --- a/ServiceBinding/RpcLiteralResponseMessageBinder.php +++ b/ServiceBinding/RpcLiteralResponseMessageBinder.php @@ -11,11 +11,64 @@ namespace BeSimple\SoapBundle\ServiceBinding; use BeSimple\SoapBundle\ServiceDefinition\Method; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType; class RpcLiteralResponseMessageBinder implements MessageBinderInterface { - public function processMessage(Method $messageDefinition, $message) + public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array()) { + $return = $messageDefinition->getReturn(); + $class = $return->getPhpType(); + + if (preg_match('/^([^\[]+)\[\]$/', $class, $match)) { + $isArray = true; + $type = + $class = $match[1]; + } else { + $isArray = false; + $type = $return->getPhpType(); + } + + if (isset($definitionComplexTypes[$type])) { + if ($class[0] == '\\') { + $class = substr($class, 1); + } + + if ($isArray) { + $array = array(); + + foreach ($message as $complexType) { + $array[] = $this->getInstanceOfStdClass($type, $class, $complexType, $definitionComplexTypes); + } + + $message = $array; + } else { + $message = $this->getInstanceOfStdClass($type, $class, $message, $definitionComplexTypes); + } + } + return $message; } + + private function getInstanceOfStdClass($type, $class, $message, $definitionComplexTypes) + { + if (get_class($message) !== $class) { + throw new \InvalidArgumentException(); + } + + $stdClass = new \stdClass(); + + foreach ($definitionComplexTypes[$type] as $type) { + if ($type instanceof PropertyComplexType) { + $stdClass->{$type->getName()} = $message->{$type->getOriginalName()}; + } elseif ($type instanceof MethodComplexType) { + $stdClass->{$type->getName()} = $message->{$type->getOriginalName()}(); + } else { + throw new \InvalidArgumentException(); + } + } + + return $stdClass; + } } \ No newline at end of file diff --git a/ServiceBinding/ServiceBinder.php b/ServiceBinding/ServiceBinder.php index aa329f1..d6d46bc 100644 --- a/ServiceBinding/ServiceBinder.php +++ b/ServiceBinding/ServiceBinder.php @@ -61,7 +61,7 @@ class ServiceBinder $result = array(); $result['_controller'] = $methodDefinition->getController(); - $result = array_merge($result, $this->requestMessageBinder->processMessage($methodDefinition, $arguments)); + $result = array_merge($result, $this->requestMessageBinder->processMessage($methodDefinition, $arguments, $this->definition->getDefinitionComplexTypes())); return $result; } @@ -70,7 +70,7 @@ class ServiceBinder { $methodDefinition = $this->definition->getMethods()->get($name); - return $this->responseMessageBinder->processMessage($methodDefinition, $return); + return $this->responseMessageBinder->processMessage($methodDefinition, $return, $this->definition->getDefinitionComplexTypes()); } protected function createSoapHeader(Header $headerDefinition, $data) diff --git a/ServiceDefinition/Annotation/MethodComplexType.php b/ServiceDefinition/Annotation/MethodComplexType.php new file mode 100644 index 0000000..cf1cdaf --- /dev/null +++ b/ServiceDefinition/Annotation/MethodComplexType.php @@ -0,0 +1,67 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Annotation; + +/** + * @Annotation + */ +class MethodComplexType extends Configuration +{ + private $name; + private $value; + private $setter; + private $isNillable = false; + + public function getName() + { + return $this->name; + } + + public function getValue() + { + return $this->value; + } + + public function getSetter() + { + return $this->setter; + } + + public function isNillable() + { + return $this->isNillable; + } + + public function setName($name) + { + $this->name = $name; + } + + public function setValue($value) + { + $this->value = $value; + } + + public function setSetter($setter) + { + $this->setter = $setter; + } + + public function setNillable($isNillable) + { + $this->isNillable = (bool) $isNillable; + } + + public function getAliasName() + { + return 'methodcomplextype'; + } +} \ No newline at end of file diff --git a/ServiceDefinition/Annotation/PropertyComplexType.php b/ServiceDefinition/Annotation/PropertyComplexType.php new file mode 100644 index 0000000..6f1f046 --- /dev/null +++ b/ServiceDefinition/Annotation/PropertyComplexType.php @@ -0,0 +1,56 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Annotation; + +/** + * @Annotation + */ +class PropertyComplexType extends Configuration +{ + private $name; + private $value; + private $isNillable = false; + + public function getName() + { + return $this->name; + } + + public function getValue() + { + return $this->value; + } + + public function isNillable() + { + return $this->isNillable; + } + + public function setName($name) + { + $this->name = $name; + } + + public function setValue($value) + { + $this->value = $value; + } + + public function setNillable($isNillable) + { + $this->isNillable = (bool) $isNillable; + } + + public function getAliasName() + { + return 'propertycomplextype'; + } +} \ No newline at end of file diff --git a/ServiceDefinition/Dumper/WsdlDumper.php b/ServiceDefinition/Dumper/WsdlDumper.php index 09548b5..7c07064 100644 --- a/ServiceDefinition/Dumper/WsdlDumper.php +++ b/ServiceDefinition/Dumper/WsdlDumper.php @@ -13,6 +13,7 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Dumper; use BeSimple\SoapBundle\ServiceDefinition\Method; use BeSimple\SoapBundle\ServiceDefinition\Type; use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition; +use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; use BeSimple\SoapBundle\Util\Assert; use BeSimple\SoapBundle\Util\QName; @@ -23,9 +24,15 @@ use Zend\Soap\Wsdl; */ class WsdlDumper implements DumperInterface { + private $loader; private $wsdl; private $definition; + public function __construct(AnnotationComplexTypeLoader $loader) + { + $this->loader = $loader; + } + public function dumpServiceDefinition(ServiceDefinition $definition, array $options = array()) { Assert::thatArgumentNotNull('definition', $definition); @@ -33,7 +40,7 @@ class WsdlDumper implements DumperInterface $options = array_merge(array('endpoint' => '', 'stylesheet' => null), $options); $this->definition = $definition; - $this->wsdl = new Wsdl($definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy()); + $this->wsdl = new Wsdl($definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition)); $port = $this->wsdl->addPortType($this->getPortTypeName()); $binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName())); diff --git a/ServiceDefinition/Dumper/WsdlTypeStrategy.php b/ServiceDefinition/Dumper/WsdlTypeStrategy.php index 8ca9acb..77aa131 100644 --- a/ServiceDefinition/Dumper/WsdlTypeStrategy.php +++ b/ServiceDefinition/Dumper/WsdlTypeStrategy.php @@ -10,13 +10,15 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Dumper; +use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition; +use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\ComplexType; use BeSimple\SoapBundle\Util\String; use Zend\Soap\Exception; use Zend\Soap\Wsdl; use Zend\Soap\Wsdl\Strategy; use Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence; -use Zend\Soap\Wsdl\Strategy\DefaultComplexType; class WsdlTypeStrategy implements Strategy { @@ -27,13 +29,16 @@ class WsdlTypeStrategy implements Strategy */ private $context; + private $loader; + private $definition; + private $typeStrategy; private $arrayStrategy; - public function __construct() + public function __construct(AnnotationComplexTypeLoader $loader, ServiceDefinition $definition) { - $this->typeStrategy = new DefaultComplexType(); - $this->arrayStrategy = new ArrayOfTypeSequence(); + $this->loader = $loader; + $this->definition = $definition; } /** @@ -51,9 +56,11 @@ class WsdlTypeStrategy implements Strategy /** * Create a complex type based on a strategy * - * @throws \Zend\Soap\WsdlException * @param string $type + * * @return string XSD type + * + * @throws \Zend\Soap\WsdlException */ public function addComplexType($type) { @@ -61,9 +68,28 @@ class WsdlTypeStrategy implements Strategy throw new \LogicException(sprintf('Cannot add complex type "%s", no context is set for this composite strategy.', $type)); } - $strategy = String::endsWith($type, '[]') ? $this->arrayStrategy : $this->typeStrategy; - $strategy->setContext($this->context); + $strategy = String::endsWith($type, '[]') ? $this->getArrayStrategy() : $this->getTypeStrategy(); return $strategy->addComplexType($type); } + + private function getArrayStrategy() + { + if (!$this->arrayStrategy) { + $this->arrayStrategy = new ArrayOfTypeSequence(); + $this->arrayStrategy->setContext($this->context); + } + + return $this->arrayStrategy; + } + + private function getTypeStrategy() + { + if (!$this->typeStrategy) { + $this->typeStrategy = new ComplexType($this->loader, $this->definition); + $this->typeStrategy->setContext($this->context); + } + + return $this->typeStrategy; + } } \ No newline at end of file diff --git a/ServiceDefinition/Loader/AnnotationClassLoader.php b/ServiceDefinition/Loader/AnnotationClassLoader.php index 2faccbc..b71732f 100644 --- a/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -32,10 +32,6 @@ use Symfony\Component\Config\Loader\LoaderResolver; */ class AnnotationClassLoader implements LoaderInterface { - private $methodAnnotationClass = 'BeSimple\\SoapBundle\\ServiceDefinition\\Annotation\\Method'; - private $paramAnnotationClass = 'BeSimple\\SoapBundle\\ServiceDefinition\\Annotation\\Param'; - private $resultAnnotationClass = 'BeSimple\\SoapBundle\\ServiceDefinition\\Annotation\\Result'; - protected $reader; /** diff --git a/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php b/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php new file mode 100644 index 0000000..21c9085 --- /dev/null +++ b/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php @@ -0,0 +1,94 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Loader; + +use BeSimple\SoapBundle\ServiceDefinition\Annotation\ComplexType; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType; +use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType; +use BeSimple\SoapBundle\Util\Collection; + +/** + * AnnotationComplexTypeLoader loads ServiceDefinition from a PHP class and its methods. + * + * Based on \Symfony\Component\Routing\Loader\AnnotationClassLoader + * + * @author Francis Besset + */ +class AnnotationComplexTypeLoader extends AnnotationClassLoader +{ + private $propertyComplexTypeClass = 'BeSimple\SoapBundle\ServiceDefinition\Annotation\PropertyComplexType'; + private $methodComplexTypeClass = 'BeSimple\SoapBundle\ServiceDefinition\Annotation\MethodComplexType'; + + /** + * Loads a ServiceDefinition from annotations from a class. + * + * @param string $class A class name + * @param string $type The resource type + * + * @return ServiceDefinition A ServiceDefinition instance + * + * @throws \InvalidArgumentException When route can't be parsed + */ + public function load($class, $type = null) + { + if (!class_exists($class)) { + throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); + } + + $class = new \ReflectionClass($class); + $collection = new Collection('getName'); + + foreach ($class->getProperties() as $property) { + if ($property->isPublic()) { + $complexType = $this->reader->getPropertyAnnotation($property, $this->propertyComplexTypeClass); + + if ($complexType) { + $propertyComplexType = new PropertyComplexType(); + $propertyComplexType->setValue($complexType->getValue()); + $propertyComplexType->setNillable($complexType->isNillable()); + + if (!$complexType->getName()) { + $propertyComplexType->setName($property->getName()); + } else { + $propertyComplexType->setName($complexType->getName()); + $propertyComplexType->setOriginalName($property->getName()); + } + + $collection->add($propertyComplexType); + } + } + } + + foreach ($class->getMethods() as $method) { + if ($method->isPublic()) { + $complexType = $this->reader->getMethodAnnotation($method, $this->methodComplexTypeClass); + + if ($complexType) { + $methodComplexType = new MethodComplexType(); + $methodComplexType->setValue($complexType->getValue()); + $methodComplexType->setSetter($complexType->getSetter()); + $methodComplexType->setNillable($complexType->isNillable()); + + if (!$complexType->getName()) { + $methodComplexType->setName($property->getName()); + } else { + $methodComplexType->setName($complexType->getName()); + $methodComplexType->setOriginalName($method->getName()); + } + + $collection->add($methodComplexType); + } + } + } + + return $collection; + } +} \ No newline at end of file diff --git a/ServiceDefinition/ServiceDefinition.php b/ServiceDefinition/ServiceDefinition.php index d11e285..683de74 100644 --- a/ServiceDefinition/ServiceDefinition.php +++ b/ServiceDefinition/ServiceDefinition.php @@ -34,6 +34,8 @@ class ServiceDefinition */ private $headers; + private $complexTypes = array(); + public function __construct($name = null, $namespace = null, array $methods = array(), array $headers = array()) { $this->setName($name); @@ -127,4 +129,14 @@ class ServiceDefinition return $types; } + + public function addDefinitionComplexType($type, Collection $complexType) + { + $this->complexTypes[$type] = $complexType; + } + + public function getDefinitionComplexTypes() + { + return $this->complexTypes; + } } \ No newline at end of file diff --git a/ServiceDefinition/Strategy/BaseComplexType.php b/ServiceDefinition/Strategy/BaseComplexType.php new file mode 100644 index 0000000..917fb57 --- /dev/null +++ b/ServiceDefinition/Strategy/BaseComplexType.php @@ -0,0 +1,62 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Strategy; + +/** + * @author Francis Besset + */ +abstract class BaseComplexType +{ + private $name; + private $originalName; + private $value; + private $isNillable = false; + + public function getName() + { + return $this->name; + } + + public function getOriginalName() + { + return $this->originalName ?: $this->name; + } + + public function getValue() + { + return $this->value; + } + + public function isNillable() + { + return $this->isNillable; + } + + public function setName($name) + { + $this->name = $name; + } + + public function setOriginalName($originalName) + { + $this->originalName = $originalName; + } + + public function setValue($value) + { + $this->value = $value; + } + + public function setNillable($isNillable) + { + $this->isNillable = (bool) $isNillable; + } +} \ No newline at end of file diff --git a/ServiceDefinition/Strategy/ComplexType.php b/ServiceDefinition/Strategy/ComplexType.php new file mode 100644 index 0000000..8af3fb1 --- /dev/null +++ b/ServiceDefinition/Strategy/ComplexType.php @@ -0,0 +1,81 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Strategy; + +use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; + +use Zend\Soap\Wsdl; +use Zend\Soap\Wsdl\Strategy\AbstractStrategy; + +/** + * @author Francis Besset + */ +class ComplexType extends AbstractStrategy +{ + private $loader; + private $definition; + + public function __construct(AnnotationComplexTypeLoader $loader, $definition) + { + $this->loader = $loader; + $this->definition = $definition; + } + + /** + * Add a complex type by recursivly using all the class properties fetched via Reflection. + * + * @param string $type Name of the class to be specified + * @return string XSD Type for the given PHP type + */ + public function addComplexType($type) + { + if (null !== $soapType = $this->scanRegisteredTypes($type)) { + return $soapType; + } + + if (!$this->loader->supports($type)) { + throw new \InvalidArgumentException(sprintf('Cannot add a complex type "%s" that is not an object or where class could not be found in "ComplexType" strategy.', $type)); + } + + $dom = $this->getContext()->toDomDocument(); + + $soapTypeName = Wsdl::translateType($type); + $soapType = 'tns:'.$soapTypeName; + + // Register type here to avoid recursion + $this->getContext()->addType($type, $soapType); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $soapTypeName); + + $all = $dom->createElement('xsd:all'); + + $definitionComplexType = $this->loader->load($type); + $this->definition->addDefinitionComplexType($type, $definitionComplexType); + + foreach ($definitionComplexType as $annotationComplexType) { + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', $propertyName = $annotationComplexType->getName()); + $element->setAttribute('type', $this->getContext()->getType(trim($annotationComplexType->getValue()))); + + if ($annotationComplexType->isNillable()) { + $element->setAttribute('nillable', 'true'); + } + + $all->appendChild($element); + } + + $complexType->appendChild($all); + $this->getContext()->getSchema()->appendChild($complexType); + + return $soapType; + } +} \ No newline at end of file diff --git a/ServiceDefinition/Strategy/MethodComplexType.php b/ServiceDefinition/Strategy/MethodComplexType.php new file mode 100644 index 0000000..7205ab5 --- /dev/null +++ b/ServiceDefinition/Strategy/MethodComplexType.php @@ -0,0 +1,29 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Strategy; + +/** + * @author Francis Besset + */ +class MethodComplexType extends BaseComplexType +{ + private $setter; + + public function getSetter() + { + return $this->setter; + } + + public function setSetter($setter) + { + $this->setter = $setter; + } +} \ No newline at end of file diff --git a/ServiceDefinition/Strategy/PropertyComplexType.php b/ServiceDefinition/Strategy/PropertyComplexType.php new file mode 100644 index 0000000..7545f0e --- /dev/null +++ b/ServiceDefinition/Strategy/PropertyComplexType.php @@ -0,0 +1,18 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceDefinition\Strategy; + +/** + * @author Francis Besset + */ +class PropertyComplexType extends BaseComplexType +{ +} \ No newline at end of file diff --git a/WebServiceContext.php b/WebServiceContext.php index 0a429ee..f0acaf6 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -70,6 +70,11 @@ class WebServiceContext return $this->serviceDefinition; } + public function getWsdlFileContent($endpoint = null) + { + return file_get_contents($this->getWsdlFile($endpoint)); + } + public function getWsdlFile($endpoint = null) { $file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint)); @@ -82,11 +87,6 @@ class WebServiceContext return (string) $cache; } - public function getWsdlFileContent($endpoint = null) - { - return file_get_contents($this->getWsdlFile($endpoint)); - } - public function getServiceBinder() { if (null === $this->serviceBinder) {