protected function addMessages(array $messages) { foreach ($messages as $message) { if (preg_match('#Header$#', $message->getName()) && $message->isEmpty()) { continue; } $messageElement = $this->document->createElement(static::WSDL_NS . ':message'); $messageElement->setAttribute('name', $message->getName()); if ($this->definition->getOption('style') === \SOAP_RPC) { foreach ($message->all() as $part) { $type = $this->definition->getTypeRepository()->getType($part->getType()); $partElement = $this->document->createElement('part'); $partElement->setAttribute('name', $part->getName()); if ($type instanceof ComplexType) { $partElement->setAttribute('type', static::TYPES_NS . ':' . $type->getXmlType()); } else { $partElement->setAttribute('type', $type); } $messageElement->appendChild($partElement); } } else { // \SOAP_DOCUMENT (literal-wrapped) $paramsComplexType = new ComplexType('array', $message->getName()); foreach ($message->all() as $part) { $partElement = $this->document->createElement(static::WSDL_NS . ':part'); $partElement->setAttribute('name', $part->getName()); $messageElement->appendChild($partElement); $partElement->setAttribute('element', static::TARGET_NS . ':' . $message->getName()); $paramsComplexType->add($part->getName(), $part->getType(), $part->isNillable()); } $paramsElement = $this->document->createElement(static::XS_NS . ':element'); $paramsElement->setAttribute('name', $paramsComplexType->getXmlType()); $paramsElement->setAttribute('type', static::TARGET_NS . ':' . $paramsComplexType->getXmlType()); $this->domSchema->appendChild($paramsElement); } $this->domDefinitions->appendChild($messageElement); } }
private function loadType($phpType) { if (false !== ($arrayOf = $this->typeRepository->getArrayOf($phpType))) { $this->loadType($arrayOf); } if (!$this->typeRepository->hasType($phpType)) { $complexTypeResolver = $this->resolve($phpType, 'annotation_complextype'); if (!$complexTypeResolver) { throw new \Exception(); } $loaded = $complexTypeResolver->load($phpType); $complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType); foreach ($loaded['properties'] as $name => $property) { $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs(), $property->getMaxOccurs()); } $this->typeRepository->addComplexType($complexType); } return $phpType; }
private function addComplexTypes(TypeRepository $typeRepository) { $foo = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\Foo', 'Foo'); $foo->add('foo', 'string'); $foo->add('bar', 'int'); $typeRepository->addComplexType($foo); $bar = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\Bar', 'Bar'); $bar->add('foo', 'string'); $bar->add('bar', 'int', true); $typeRepository->addComplexType($bar); $fooBar = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\FooBar', 'FooBar'); $fooBar->add('foo', 'BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\Foo'); $fooBar->add('bar', 'BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\Bar'); $typeRepository->addComplexType($fooBar); $simpleArrays = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\SimpleArrays', 'SimpleArrays'); $simpleArrays->add('array1', 'string[]', true); $simpleArrays->add('array2', 'string[]'); $simpleArrays->add('array3', 'string[]'); $typeRepository->addComplexType($simpleArrays); $fooRecursive = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\FooRecursive', 'FooRecursive'); $fooRecursive->add('bar', 'BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\BarRecursive'); $typeRepository->addComplexType($fooRecursive); $barRecursive = new ComplexType('BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\BarRecursive', 'BarRecursive'); $barRecursive->add('foo', 'BeSimple\\SoapBundle\\Tests\\fixtures\\ServiceBinding\\FooRecursive'); $typeRepository->addComplexType($barRecursive); return $typeRepository; }