diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index 163590b..5c6b6b3 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -30,7 +30,7 @@ use Bundle\WebServiceBundle\Converter\ConverterRepository; use Bundle\WebServiceBundle\Util\String; /** - * + * * * @author Christian Kerl */ @@ -84,7 +84,7 @@ class SoapWebServiceController extends ContainerAware $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); $this->serviceBinder = $webServiceContext->getServiceBinder(); - + $this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->soapResponse); $this->soapServer->setObject($this); @@ -93,31 +93,28 @@ class SoapWebServiceController extends ContainerAware $this->soapServer->handle($this->soapRequest->getSoapMessage()); } $soapResponseContent = ob_get_clean(); - + $this->soapResponse->setContent($soapResponseContent); return $this->soapResponse; } public function definition($webservice) - { + { $webServiceContext = $this->container->get('webservice.context.' . $webservice); - $request = $this->container->get('request'); - - if($request->query->has('WSDL')) - { + $request = $this->container->get('request'); + + if($request->query->has('WSDL')) { $endpoint = $this->container->get('router')->generate('_webservice_call', array('webservice' => $webservice), true); - + $response = new Response($webServiceContext->getWsdlFileContent($endpoint)); $response->headers->set('Content-Type', 'application/wsdl+xml'); - } - else - { + } else { // TODO: replace with better represantation $response = new Response($webServiceContext->getWsdlFileContent()); $response->headers->set('Content-Type', 'text/xml'); } - + return $response; } @@ -132,8 +129,7 @@ class SoapWebServiceController extends ContainerAware */ public function __call($method, $arguments) { - if($this->serviceBinder->isServiceHeader($method)) - { + if($this->serviceBinder->isServiceHeader($method)) { // collect request soap headers $this->soapRequest->getSoapHeaders()->add( $this->serviceBinder->processServiceHeader($method, $arguments[0]) @@ -142,8 +138,7 @@ class SoapWebServiceController extends ContainerAware return; } - if($this->serviceBinder->isServiceMethod($method)) - { + if($this->serviceBinder->isServiceMethod($method)) { $this->soapRequest->attributes->add( $this->serviceBinder->processServiceMethodArguments($method, $arguments) ); @@ -154,8 +149,7 @@ class SoapWebServiceController extends ContainerAware $this->soapResponse = $this->checkResponse($response); // add response soap headers to soap server - foreach($this->soapResponse->getSoapHeaders() as $header) - { + foreach($this->soapResponse->getSoapHeaders() as $header) { $this->soapServer->addSoapHeader($header->toNativeSoapHeader()); } @@ -178,11 +172,10 @@ class SoapWebServiceController extends ContainerAware */ protected function checkResponse(Response $response) { - if($response == null || !$response instanceof SoapResponse) - { + if($response == null || !$response instanceof SoapResponse) { throw new \InvalidArgumentException(); } return $response; } -} +} \ No newline at end of file diff --git a/Converter/ConverterRepository.php b/Converter/ConverterRepository.php index 90db9e1..8882a4d 100644 --- a/Converter/ConverterRepository.php +++ b/Converter/ConverterRepository.php @@ -38,11 +38,5 @@ class ConverterRepository public function registerTypeConverterServices(ContainerInterface $container) { - /* - foreach($container->findTaggedServiceIds('webservice.converter') as $id => $attributes) - { - $this->addTypeConverter($container->get($id)); - } - */ } -} +} \ No newline at end of file diff --git a/Converter/TypeConverterInterface.php b/Converter/TypeConverterInterface.php index d9453b9..096cb0b 100644 --- a/Converter/TypeConverterInterface.php +++ b/Converter/TypeConverterInterface.php @@ -27,4 +27,4 @@ interface TypeConverterInterface function convertXmlToPhp(SoapRequest $request, $data); function convertPhpToXml(SoapResponse $response, $data); -} +} \ No newline at end of file diff --git a/Converter/XopIncludeTypeConverter.php b/Converter/XopIncludeTypeConverter.php index 385a8ad..7f1037c 100644 --- a/Converter/XopIncludeTypeConverter.php +++ b/Converter/XopIncludeTypeConverter.php @@ -42,8 +42,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface $ref = $include->getAttribute('href'); - if(String::startsWith($ref, 'cid:')) - { + if(String::startsWith($ref, 'cid:')) { $cid = urldecode(substr($ref, 4)); return $request->getSoapAttachments()->get($cid)->getContent(); @@ -56,4 +55,4 @@ class XopIncludeTypeConverter implements TypeConverterInterface { return $data; } -} +} \ No newline at end of file diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3939b3e..1dadea7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -61,4 +61,4 @@ class Configuration return $treeBuilder->buildTree(); } -} +} \ No newline at end of file diff --git a/DependencyInjection/WebServiceExtension.php b/DependencyInjection/WebServiceExtension.php index ac24586..8d6a34e 100644 --- a/DependencyInjection/WebServiceExtension.php +++ b/DependencyInjection/WebServiceExtension.php @@ -31,21 +31,20 @@ class WebServiceExtension extends Extension { // maps config options to service suffix' private $bindingConfigToServiceSuffixMap = array('rpc-literal' => '.rpcliteral', 'document-wrapped' => '.documentwrapped'); - + public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('annotations.xml'); $loader->load('webservice.xml'); - + $processor = new Processor(); $configuration = new Configuration(); $config = $processor->process($configuration->getConfigTree(), $configs); - - foreach($config['services'] as $serviceContextConfig) - { + + foreach($config['services'] as $serviceContextConfig) { $this->createWebServiceContext($serviceContextConfig, $container); } } @@ -55,20 +54,19 @@ class WebServiceExtension extends Extension $bindingDependentArguments = array(1, 3, 4); $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; unset($config['binding']); - + $contextPrototype = $container->getDefinition('webservice.context'); $contextPrototypeArguments = $contextPrototype->getArguments(); - + $contextId = 'webservice.context.' . $config['name']; $context = $container->setDefinition($contextId, new DefinitionDecorator('webservice.context')); - - foreach($bindingDependentArguments as $idx) - { + + foreach($bindingDependentArguments as $idx) { $context->setArgument($idx, new Reference($contextPrototypeArguments[$idx] . $bindingSuffix)); } $context->setArgument(5, array_merge($contextPrototypeArguments[5], $config)); } - + public function getNamespace() { return null; diff --git a/README.markdown b/README.markdown index 8cd5bbc..ee2f472 100644 --- a/README.markdown +++ b/README.markdown @@ -15,15 +15,15 @@ QuickStart * Put WebServiceBundle in your `src/Bundle` dir * Enable WebServiceBundle in your `app/AppKernel.php` - + * Include the WebServiceBundle's routing configuration in `app/config/routing.yml` (you can choose the prefix arbitrarily) - + _ws: resource: "@WebServiceBundle/Resources/config/routing/webservicecontroller.xml" prefix: /ws - + * Configure your first web service in `app/config/config.yml` - + web_service: services: demoapi: diff --git a/Resources/config/routing/webservicecontroller.xml b/Resources/config/routing/webservicecontroller.xml index 7d86541..ae2c83b 100644 --- a/Resources/config/routing/webservicecontroller.xml +++ b/Resources/config/routing/webservicecontroller.xml @@ -4,12 +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"> - - webservice.controller:call - POST - - - webservice.controller:definition - GET - + + webservice.controller:call + POST + + + + webservice.controller:definition + GET + diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index 0c1a07e..6b93d64 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -3,57 +3,48 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - Symfony\Component\HttpKernel\Config\FileLocator - + + Symfony\Component\HttpKernel\Config\FileLocator + %kernel.cache_dir%/webservice - - - - + + + + - - - - - - + + + + + - + - %webservice.cache_dir% - - - - - + + + + - - - - - - - + + + + + + + - - + + - + @@ -65,14 +56,9 @@ - - - - - - + + \ No newline at end of file diff --git a/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php b/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php index 59409eb..df3e118 100644 --- a/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php +++ b/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php @@ -16,16 +16,14 @@ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterfa { public function processMessage(Method $messageDefinition, $message) { - if(count($message) > 1) - { + if(count($message) > 1) { throw new \InvalidArgumentException(); } $result = array(); $message = $message[0]; - foreach($messageDefinition->getArguments() as $argument) - { + foreach($messageDefinition->getArguments() as $argument) { $result[$argument->getName()] = $message->{$argument->getName()}; } diff --git a/ServiceBinding/MessageBinderInterface.php b/ServiceBinding/MessageBinderInterface.php index 876fb99..6dc9bf5 100644 --- a/ServiceBinding/MessageBinderInterface.php +++ b/ServiceBinding/MessageBinderInterface.php @@ -15,8 +15,6 @@ use Bundle\WebServiceBundle\ServiceDefinition\Method; interface MessageBinderInterface { /** - * - * * @param Method $messageDefinition * @param mixed $message * diff --git a/ServiceBinding/RpcLiteralRequestMessageBinder.php b/ServiceBinding/RpcLiteralRequestMessageBinder.php index 50590f7..d845ed6 100644 --- a/ServiceBinding/RpcLiteralRequestMessageBinder.php +++ b/ServiceBinding/RpcLiteralRequestMessageBinder.php @@ -19,9 +19,9 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $result = array(); $i = 0; - foreach($messageDefinition->getArguments() as $argument) - { + foreach($messageDefinition->getArguments() as $argument) { $result[$argument->getName()] = $message[$i]; + $i++; } diff --git a/ServiceDefinition/Annotation/Method.php b/ServiceDefinition/Annotation/Method.php index f91abd0..2c0b53e 100644 --- a/ServiceDefinition/Annotation/Method.php +++ b/ServiceDefinition/Annotation/Method.php @@ -14,18 +14,18 @@ class Method { private $name; private $service; - + public function __construct($values) { $this->name = isset($values['value']) ? $values['value'] : null; $this->service = isset($values['service']) ? $values['service'] : null; } - + public function getName($default = null) { return $this->name !== null ? $this->name : $default; } - + public function getService() { return $this->service; diff --git a/ServiceDefinition/Annotation/Param.php b/ServiceDefinition/Annotation/Param.php index 6bc3d55..6bb4f0d 100644 --- a/ServiceDefinition/Annotation/Param.php +++ b/ServiceDefinition/Annotation/Param.php @@ -13,14 +13,14 @@ namespace Bundle\WebServiceBundle\ServiceDefinition\Annotation; class Param extends TypedElement { private $name; - + public function __construct($values) { parent::__construct($values); - + $this->name = $values['value']; } - + public function getName() { return $this->name; diff --git a/ServiceDefinition/Annotation/Result.php b/ServiceDefinition/Annotation/Result.php index 429c50b..596c5d2 100644 --- a/ServiceDefinition/Annotation/Result.php +++ b/ServiceDefinition/Annotation/Result.php @@ -11,7 +11,7 @@ namespace Bundle\WebServiceBundle\ServiceDefinition\Annotation; class Result extends TypedElement -{ +{ public function __construct($values) { parent::__construct($values); diff --git a/ServiceDefinition/Annotation/TypedElement.php b/ServiceDefinition/Annotation/TypedElement.php index eb75b66..9d7209c 100644 --- a/ServiceDefinition/Annotation/TypedElement.php +++ b/ServiceDefinition/Annotation/TypedElement.php @@ -14,7 +14,7 @@ abstract class TypedElement { private $phpType; private $xmlType; - + public function __construct($values) { foreach(array('type', 'phpType') as $key) @@ -24,15 +24,15 @@ abstract class TypedElement $this->phpType = $values[$key]; } } - + $this->xmlType = isset($values['xmlType']) ? $values['xmlType'] : null; } - + public function getPhpType() { return $this->phpType; } - + public function getXmlType() { return $this->xmlType; diff --git a/ServiceDefinition/Dumper/WsdlDumper.php b/ServiceDefinition/Dumper/WsdlDumper.php index 24c31cd..c21556d 100644 --- a/ServiceDefinition/Dumper/WsdlDumper.php +++ b/ServiceDefinition/Dumper/WsdlDumper.php @@ -25,35 +25,32 @@ use Zend\Soap\Wsdl; class WsdlDumper implements DumperInterface { private $definition; - + public function dumpServiceDefinition(ServiceDefinition $definition, array $options = array()) { Assert::thatArgumentNotNull('definition', $definition); $options = array_merge(array('endpoint' => ''), $options); - + $this->definition = $definition; $wsdl = new Wsdl($definition->getName(), $definition->getNamespace()); $port = $wsdl->addPortType($this->getPortTypeName()); $binding = $wsdl->addBinding($this->getBindingName(), 'tns:' . $this->getPortTypeName()); - + $wsdl->addSoapBinding($binding, 'rpc'); $wsdl->addService($this->getServiceName(), $this->getPortName(), 'tns:' . $this->getBindingName(), $options['endpoint']); - foreach($definition->getMethods() as $method) - { + foreach($definition->getMethods() as $method) { $requestParts = array(); $responseParts = array(); - foreach($method->getArguments() as $argument) - { + foreach($method->getArguments() as $argument) { $requestParts[$argument->getName()] = $wsdl->getType($argument->getType()->getPhpType()); } - if($method->getReturn() !== null) - { + if($method->getReturn() !== null) { $responseParts['return'] = $wsdl->getType($method->getReturn()->getPhpType()); } @@ -83,7 +80,7 @@ class WsdlDumper implements DumperInterface $this->definition = null; $wsdl->toDomDocument()->formatOutput = true; - + return $wsdl->toXml(); } @@ -91,7 +88,7 @@ class WsdlDumper implements DumperInterface { return $this->definition->getName() . 'Port'; } - + protected function getPortTypeName() { return $this->definition->getName() . 'PortType'; @@ -121,4 +118,4 @@ class WsdlDumper implements DumperInterface { return $this->definition->getNamespace() . $method->getName(); } -} +} \ No newline at end of file diff --git a/ServiceDefinition/Loader/AnnotationClassLoader.php b/ServiceDefinition/Loader/AnnotationClassLoader.php index ee82665..4c97c34 100644 --- a/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -35,9 +35,9 @@ class AnnotationClassLoader implements LoaderInterface private $wsMethodAnnotationClass = 'Bundle\\WebServiceBundle\\ServiceDefinition\\Annotation\\Method'; private $wsParamAnnotationClass = 'Bundle\\WebServiceBundle\\ServiceDefinition\\Annotation\\Param'; private $wsResultAnnotationClass = 'Bundle\\WebServiceBundle\\ServiceDefinition\\Annotation\\Result'; - + protected $reader; - + /** * Constructor. * @@ -60,42 +60,37 @@ class AnnotationClassLoader implements LoaderInterface */ public function load($class, $type = null) { - if (!class_exists($class)) - { + if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } $class = new \ReflectionClass($class); $definition = new ServiceDefinition(); - - foreach ($class->getMethods() as $method) - { + + foreach ($class->getMethods() as $method) { $wsMethodAnnot = $this->reader->getMethodAnnotation($method, $this->wsMethodAnnotationClass); - - if($wsMethodAnnot !== null) - { + + if($wsMethodAnnot !== null) { $wsParamAnnots = $this->reader->getMethodAnnotations($method, $this->wsParamAnnotationClass); $wsResultAnnot = $this->reader->getMethodAnnotation($method, $this->wsResultAnnotationClass); - + $serviceMethod = new Method(); $serviceMethod->setName($wsMethodAnnot->getName($method->getName())); $serviceMethod->setController($this->getController($method, $wsMethodAnnot)); - - foreach($wsParamAnnots as $wsParamAnnot) - { + + foreach($wsParamAnnots as $wsParamAnnot) { $serviceArgument = new Argument(); $serviceArgument->setName($wsParamAnnot->getName()); $serviceArgument->setType(new Type($wsParamAnnot->getPhpType(), $wsParamAnnot->getXmlType())); - + $serviceMethod->getArguments()->add($serviceArgument); } - - if($wsResultAnnot !== null) - { + + if($wsResultAnnot !== null) { $serviceMethod->setReturn(new Type($wsResultAnnot->getPhpType(), $wsResultAnnot->getXmlType())); } - + $definition->getMethods()->add($serviceMethod); } } @@ -105,16 +100,13 @@ class AnnotationClassLoader implements LoaderInterface private function getController(\ReflectionMethod $method, MethodAnnotation $annotation) { - if($annotation->getService() !== null) - { + if($annotation->getService() !== null) { return $annotation->getService() . ':' . $method->name; - } - else - { + } else { return $method->class . '::' . $method->name; } } - + /** * Returns true if this class supports the given resource. * @@ -145,4 +137,4 @@ class AnnotationClassLoader implements LoaderInterface public function getResolver() { } -} +} \ No newline at end of file diff --git a/ServiceDefinition/Loader/AnnotationFileLoader.php b/ServiceDefinition/Loader/AnnotationFileLoader.php index 6c13d7d..6d7f405 100644 --- a/ServiceDefinition/Loader/AnnotationFileLoader.php +++ b/ServiceDefinition/Loader/AnnotationFileLoader.php @@ -61,11 +61,11 @@ class AnnotationFileLoader extends FileLoader $path = $this->locator->locate($file); $definition = new ServiceDefinition(); - + if ($class = $this->findClass($path)) { $definition = $this->loader->load($class, $type); } - + return $definition; } @@ -87,7 +87,7 @@ class AnnotationFileLoader extends FileLoader * * @param string $file A PHP file path * - * @return string|false Full class name if found, false otherwise + * @return string|false Full class name if found, false otherwise */ protected function findClass($file) { diff --git a/ServiceDefinition/Loader/AnnotationParser.php b/ServiceDefinition/Loader/AnnotationParser.php index 7b6f523..afd9c1b 100644 --- a/ServiceDefinition/Loader/AnnotationParser.php +++ b/ServiceDefinition/Loader/AnnotationParser.php @@ -15,7 +15,7 @@ use Doctrine\Common\Annotations\Parser; /** * AnnotationParser allows multiple annotations of the same class to be present. - * + * * @author Christian Kerl */ class AnnotationParser extends Parser diff --git a/ServiceDefinition/Loader/AnnotationReader.php b/ServiceDefinition/Loader/AnnotationReader.php index 81e3f03..b65d48d 100644 --- a/ServiceDefinition/Loader/AnnotationReader.php +++ b/ServiceDefinition/Loader/AnnotationReader.php @@ -22,19 +22,18 @@ class AnnotationReader extends BaseAnnotationReader public function getMethodAnnotation(\ReflectionMethod $method, $type) { $annotation = parent::getMethodAnnotation($method, $type); - - if($annotation !== null && count($annotation) > 1) - { + + if($annotation !== null && count($annotation) > 1) { throw new \LogicException(sprintf("There is more than one annotation of type '%s'!", $type)); } - + return $annotation !== null ? $annotation[0] : null; } - + public function getMethodAnnotations(\ReflectionMethod $method, $type = null) { $annotations = parent::getMethodAnnotations($method); - + return $type !== null && isset($annotations[$type]) ? $annotations[$type] : $annotations; } } \ No newline at end of file diff --git a/ServiceDefinition/Loader/XmlFileLoader.php b/ServiceDefinition/Loader/XmlFileLoader.php index 3189d7a..feefed5 100644 --- a/ServiceDefinition/Loader/XmlFileLoader.php +++ b/ServiceDefinition/Loader/XmlFileLoader.php @@ -24,27 +24,25 @@ class XmlFileLoader extends FileLoader { return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION); } - + public function load($file, $type = null) { $path = $this->locator->locate($file); - + $xml = $this->parseFile($path); $definition = new ServiceDefinition(); $definition->setName((string) $xml['name']); $definition->setNamespace((string) $xml['namespace']); - foreach($xml->header as $header) - { + foreach($xml->header as $header) { $definition->getHeaders()->add($this->parseHeader($header)); } - foreach($xml->method as $method) - { + foreach($xml->method as $method) { $definition->getMethods()->add($this->parseMethod($method)); } - + return $definition; } @@ -69,8 +67,7 @@ class XmlFileLoader extends FileLoader { $method = new Method((string)$node['name'], (string)$node['controller']); - foreach($node->argument as $argument) - { + foreach($node->argument as $argument) { $method->getArguments()->add($this->parseArgument($argument)); } diff --git a/ServiceDefinition/Loader/schema/servicedefinition-1.0.xsd b/ServiceDefinition/Loader/schema/servicedefinition-1.0.xsd index ed2d68f..4ef903a 100644 --- a/ServiceDefinition/Loader/schema/servicedefinition-1.0.xsd +++ b/ServiceDefinition/Loader/schema/servicedefinition-1.0.xsd @@ -1,81 +1,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Soap/SoapRequest.php b/Soap/SoapRequest.php index 3f4b325..5cfbf6f 100644 --- a/Soap/SoapRequest.php +++ b/Soap/SoapRequest.php @@ -28,7 +28,7 @@ class SoapRequest extends Request { return new static($request->query->all(), $request->request->all(), $request->attributes->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->content); } - + /** * @var string */ @@ -67,8 +67,7 @@ class SoapRequest extends Request */ public function getSoapMessage() { - if($this->soapMessage === null) - { + if($this->soapMessage === null) { $this->soapMessage = $this->initializeSoapMessage(); } @@ -87,19 +86,14 @@ class SoapRequest extends Request protected function initializeSoapMessage() { - if($this->server->has('CONTENT_TYPE')) - { + if($this->server->has('CONTENT_TYPE')) { $type = $this->splitContentTypeHeader($this->server->get('CONTENT_TYPE')); - switch($type['_type']) - { + switch($type['_type']) { case 'multipart/related': - if($type['type'] == 'application/xop+xml') - { + if($type['type'] == 'application/xop+xml') { return $this->initializeMtomSoapMessage($type, $this->getContent()); - } - else - { + } else { //log error } break; @@ -118,8 +112,7 @@ class SoapRequest extends Request protected function initializeMtomSoapMessage(array $contentTypeHeader, $content) { - if(!isset($contentTypeHeader['start']) || !isset($contentTypeHeader['start-info']) || !isset($contentTypeHeader['boundary'])) - { + if(!isset($contentTypeHeader['start']) || !isset($contentTypeHeader['start-info']) || !isset($contentTypeHeader['boundary'])) { throw new \InvalidArgumentException(); } @@ -134,13 +127,11 @@ class SoapRequest extends Request // TODO: add more checks to achieve full compatibility to MTOM spec // http://www.w3.org/TR/soap12-mtom/ - if($rootPart->id != $soapMimePartId || $rootPartType['_type'] != 'application/xop+xml' || $rootPartType['type'] != $soapMimePartType) - { + if($rootPart->id != $soapMimePartId || $rootPartType['_type'] != 'application/xop+xml' || $rootPartType['type'] != $soapMimePartType) { throw new \InvalidArgumentException(); } - foreach($mimeParts as $mimePart) - { + foreach($mimeParts as $mimePart) { $this->soapAttachments->add(new SoapAttachment( $mimePart->id, $mimePart->type, @@ -160,8 +151,7 @@ class SoapRequest extends Request $result['_type'] = array_shift($parts); - foreach($parts as $part) - { + foreach($parts as $part) { list($key, $value) = explode('=', trim($part), 2); $result[$key] = trim($value, '"'); @@ -169,4 +159,4 @@ class SoapRequest extends Request return $result; } -} +} \ No newline at end of file diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index 302ab19..6402649 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -57,8 +57,7 @@ class SoapServerFactory { $result = array(); - foreach($this->converters->getTypeConverters() as $typeConverter) - { + foreach($this->converters->getTypeConverters() as $typeConverter) { $result[] = array( 'type_name' => $typeConverter->getTypeName(), 'type_ns' => $typeConverter->getTypeNamespace(), @@ -78,15 +77,12 @@ class SoapServerFactory { $result = array(); - foreach($this->definition->getHeaders() as $header) - { + foreach($this->definition->getHeaders() as $header) { $this->addSoapServerClassmapEntry($result, $header->getType()); } - foreach($this->definition->getMethods() as $method) - { - foreach($method->getArguments() as $arg) - { + foreach($this->definition->getMethods() as $method) { + foreach($method->getArguments() as $arg) { $this->addSoapServerClassmapEntry($result, $arg->getType()); } } @@ -98,15 +94,14 @@ class SoapServerFactory { // TODO: fix this hack if($type->getXmlType() === null) return; - + $xmlType = QName::fromPackedQName($type->getXmlType())->getName(); $phpType = $type->getPhpType(); - if(isset($classmap[$xmlType]) && $classmap[$xmlType] != $phpType) - { + if(isset($classmap[$xmlType]) && $classmap[$xmlType] != $phpType) { // log warning } $classmap[$xmlType] = $phpType; } -} +} \ No newline at end of file diff --git a/Tests/fixtures/api-servicedefinition.xml b/Tests/fixtures/api-servicedefinition.xml index 952f1a3..3fc5d75 100644 --- a/Tests/fixtures/api-servicedefinition.xml +++ b/Tests/fixtures/api-servicedefinition.xml @@ -1,14 +1,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/Tests/fixtures/api.wsdl b/Tests/fixtures/api.wsdl index c20abed..d2f8cef 100644 --- a/Tests/fixtures/api.wsdl +++ b/Tests/fixtures/api.wsdl @@ -1,145 +1,145 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Util/Assert.php b/Util/Assert.php index 93daab8..95563ab 100644 --- a/Util/Assert.php +++ b/Util/Assert.php @@ -21,8 +21,7 @@ class Assert public static function thatArgument($name, $condition, $message = self::ARGUMENT_INVALID) { - if(!$condition) - { + if(!$condition) { throw new \InvalidArgumentException(sprintf($message, $name)); } } diff --git a/Util/Collection.php b/Util/Collection.php index 5afe7d9..8828900 100644 --- a/Util/Collection.php +++ b/Util/Collection.php @@ -27,8 +27,7 @@ class Collection implements \IteratorAggregate, \Countable public function addAll($elements) { - foreach ($elements as $element) - { + foreach ($elements as $element) { $this->add($element); } } diff --git a/Util/String.php b/Util/String.php index 1c641d5..0526453 100644 --- a/Util/String.php +++ b/Util/String.php @@ -17,35 +17,34 @@ namespace Bundle\WebServiceBundle\Util; */ class String { - /** - * Checks if a string starts with a given string. - * - * @param string $str A string - * @param string $substr A string to check against - * - * @return bool True if str starts with substr - */ - public static function startsWith($str, $substr) - { - if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) + /** + * Checks if a string starts with a given string. + * + * @param string $str A string + * @param string $substr A string to check against + * + * @return bool True if str starts with substr + */ + public static function startsWith($str, $substr) { - return $substr == substr($str, 0, strlen($substr)); + if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) { + return $substr == substr($str, 0, strlen($substr)); + } } - } - /** - * Checks if a string ends with a given string. - * - * @param string $str A string - * @param string $substr A string to check against - * - * @return bool True if str ends with substr - */ - public static function endsWith($str, $substr) - { - if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) + /** + * Checks if a string ends with a given string. + * + * @param string $str A string + * @param string $substr A string to check against + * + * @return bool True if str ends with substr + */ + public static function endsWith($str, $substr) { - return $substr == substr($str, strlen($str) - strlen($substr)); + if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) + { + return $substr == substr($str, strlen($str) - strlen($substr)); + } } - } } \ No newline at end of file diff --git a/WebServiceContext.php b/WebServiceContext.php index ce764bb..8bdd949 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -30,81 +30,76 @@ class WebServiceContext private $converterRepository; private $requestMessageBinder; private $responseMessageBinder; - + private $serviceDefinitionLoader; private $wsdlFileDumper; - + private $options; - + private $serviceDefinition; private $serviceBinder; private $serverFactory; - + public function __construct(LoaderInterface $loader, DumperInterface $dumper, ConverterRepository $converterRepository, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder, array $options) { $this->serviceDefinitionLoader = $loader; $this->wsdlFileDumper = $dumper; - + $this->converterRepository = $converterRepository; $this->requestMessageBinder = $requestMessageBinder; $this->responseMessageBinder = $responseMessageBinder; - + $this->options = $options; } - - public function getServiceDefinition() + + public function getServiceDefinition() { - if($this->serviceDefinition === null) - { - if(!$this->serviceDefinitionLoader->supports($this->options['resource'], $this->options['resource_type'])) - { + if($this->serviceDefinition === null) { + if(!$this->serviceDefinitionLoader->supports($this->options['resource'], $this->options['resource_type'])) { throw new \LogicException(); } - + $this->serviceDefinition = $this->serviceDefinitionLoader->load($this->options['resource'], $this->options['resource_type']); $this->serviceDefinition->setName($this->options['name']); $this->serviceDefinition->setNamespace($this->options['namespace']); } - + return $this->serviceDefinition; } - + public function getWsdlFile($endpoint = null) { $id = $endpoint !== null ? '.' . md5($endpoint) : ''; $file = sprintf('%s/%s.wsdl', $this->options['cache_dir'], $this->options['name'] . $id); $cache = new ConfigCache($file, true); - - if(!$cache->isFresh()) - { + + if(!$cache->isFresh()) { $cache->write($this->wsdlFileDumper->dumpServiceDefinition($this->getServiceDefinition(), array('endpoint' => $endpoint))); } - + return $file; } - + public function getWsdlFileContent($endpoint = null) { return file_get_contents($this->getWsdlFile($endpoint)); } - - public function getServiceBinder() + + public function getServiceBinder() { - if($this->serviceBinder === null) - { + if($this->serviceBinder === null) { $this->serviceBinder = new ServiceBinder($this->getServiceDefinition(), $this->requestMessageBinder, $this->responseMessageBinder); } - + return $this->serviceBinder; } - - public function getServerFactory() + + public function getServerFactory() { - if($this->serverFactory === null) - { + if($this->serverFactory === null) { $this->serverFactory = new SoapServerFactory($this->getServiceDefinition(), $this->getWsdlFile(), $this->converterRepository); } - + return $this->serverFactory; } } \ No newline at end of file