Cleaned files
This commit is contained in:
parent
7ddf05cec1
commit
51d1d28830
|
@ -104,15 +104,12 @@ class SoapWebServiceController extends ContainerAware
|
|||
$webServiceContext = $this->container->get('webservice.context.' . $webservice);
|
||||
$request = $this->container->get('request');
|
||||
|
||||
if($request->query->has('WSDL'))
|
||||
{
|
||||
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');
|
||||
|
@ -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,8 +172,7 @@ class SoapWebServiceController extends ContainerAware
|
|||
*/
|
||||
protected function checkResponse(Response $response)
|
||||
{
|
||||
if($response == null || !$response instanceof SoapResponse)
|
||||
{
|
||||
if($response == null || !$response instanceof SoapResponse) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,11 +38,5 @@ class ConverterRepository
|
|||
|
||||
public function registerTypeConverterServices(ContainerInterface $container)
|
||||
{
|
||||
/*
|
||||
foreach($container->findTaggedServiceIds('webservice.converter') as $id => $attributes)
|
||||
{
|
||||
$this->addTypeConverter($container->get($id));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -44,8 +44,7 @@ class WebServiceExtension extends Extension
|
|||
|
||||
$config = $processor->process($configuration->getConfigTree(), $configs);
|
||||
|
||||
foreach($config['services'] as $serviceContextConfig)
|
||||
{
|
||||
foreach($config['services'] as $serviceContextConfig) {
|
||||
$this->createWebServiceContext($serviceContextConfig, $container);
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +61,7 @@ class WebServiceExtension extends Extension
|
|||
$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));
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<default key="_controller">webservice.controller:call</default>
|
||||
<requirement key="_method">POST</requirement>
|
||||
</route>
|
||||
|
||||
<route id="_webservice_definition" pattern="/{webservice}">
|
||||
<default key="_controller">webservice.controller:definition</default>
|
||||
<requirement key="_method">GET</requirement>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
</service>
|
||||
|
||||
<service id="webservice.context" class="Bundle\WebServiceBundle\WebServiceContext" abstract="true">
|
||||
|
||||
<argument type="service" id="webservice.definition.loader"/>
|
||||
<argument type="service" id="webservice.definition.dumper.wsdl"/>
|
||||
<argument type="service" id="webservice.converter.repository"/>
|
||||
|
@ -24,16 +23,8 @@
|
|||
<argument type="service" id="webservice.binder.response"/>
|
||||
|
||||
<argument type="collection">
|
||||
<!--
|
||||
<argument key="name">%webservice.name%</argument>
|
||||
<argument key="namespace">%webservice.namespace%</argument>
|
||||
|
||||
<argument key="resource">%webservice.resource%</argument>
|
||||
<argument key="resource_type">%webservice.resource_type%</argument>
|
||||
-->
|
||||
<argument key="cache_dir">%webservice.cache_dir%</argument>
|
||||
</argument>
|
||||
|
||||
</service>
|
||||
|
||||
<service id="webservice.binder.request.rpcliteral" class="Bundle\WebServiceBundle\ServiceBinding\RpcLiteralRequestMessageBinder" />
|
||||
|
@ -69,10 +60,5 @@
|
|||
<service id="webservice.definition.dumper.wsdl.rpcliteral" class="Bundle\WebServiceBundle\ServiceDefinition\Dumper\WsdlDumper">
|
||||
|
||||
</service>
|
||||
<!--
|
||||
<service id="webservice.definition.dumper.wsdl.documentwrapped" class="">
|
||||
|
||||
</service>
|
||||
-->
|
||||
</services>
|
||||
</container>
|
|
@ -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()};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ use Bundle\WebServiceBundle\ServiceDefinition\Method;
|
|||
interface MessageBinderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param Method $messageDefinition
|
||||
* @param mixed $message
|
||||
*
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,18 +42,15 @@ class WsdlDumper implements DumperInterface
|
|||
$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());
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ 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));
|
||||
}
|
||||
|
||||
|
@ -69,12 +68,10 @@ class AnnotationClassLoader implements LoaderInterface
|
|||
|
||||
$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);
|
||||
|
||||
|
@ -82,8 +79,7 @@ class AnnotationClassLoader implements LoaderInterface
|
|||
$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()));
|
||||
|
@ -91,8 +87,7 @@ class AnnotationClassLoader implements LoaderInterface
|
|||
$serviceMethod->getArguments()->add($serviceArgument);
|
||||
}
|
||||
|
||||
if($wsResultAnnot !== null)
|
||||
{
|
||||
if($wsResultAnnot !== null) {
|
||||
$serviceMethod->setReturn(new Type($wsResultAnnot->getPhpType(), $wsResultAnnot->getXmlType()));
|
||||
}
|
||||
|
||||
|
@ -105,12 +100,9 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ class AnnotationReader extends BaseAnnotationReader
|
|||
{
|
||||
$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));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,11 @@ class XmlFileLoader extends FileLoader
|
|||
$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));
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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, '"');
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +98,7 @@ class SoapServerFactory
|
|||
$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
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ class Collection implements \IteratorAggregate, \Countable
|
|||
|
||||
public function addAll($elements)
|
||||
{
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
foreach ($elements as $element) {
|
||||
$this->add($element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ class String
|
|||
*/
|
||||
public static function startsWith($str, $substr)
|
||||
{
|
||||
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr))
|
||||
{
|
||||
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
|
||||
return $substr == substr($str, 0, strlen($substr));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,8 @@ class WebServiceContext
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -75,8 +73,7 @@ class WebServiceContext
|
|||
$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)));
|
||||
}
|
||||
|
||||
|
@ -90,8 +87,7 @@ class WebServiceContext
|
|||
|
||||
public function getServiceBinder()
|
||||
{
|
||||
if($this->serviceBinder === null)
|
||||
{
|
||||
if($this->serviceBinder === null) {
|
||||
$this->serviceBinder = new ServiceBinder($this->getServiceDefinition(), $this->requestMessageBinder, $this->responseMessageBinder);
|
||||
}
|
||||
|
||||
|
@ -100,8 +96,7 @@ class WebServiceContext
|
|||
|
||||
public function getServerFactory()
|
||||
{
|
||||
if($this->serverFactory === null)
|
||||
{
|
||||
if($this->serverFactory === null) {
|
||||
$this->serverFactory = new SoapServerFactory($this->getServiceDefinition(), $this->getWsdlFile(), $this->converterRepository);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue