/** * @inheritdoc */ public function generateSoapHeaderIfNeeded(DOMDocument $DOMDocument, $targetNamespace, $soapHeaderMessage = '', Parameter $header = null, $soapVersion) { if ($header) { return XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes($soapVersion . ':header', array('use' => 'encoded', 'namespace' => $targetNamespace, 'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/', 'part' => $header->getNode()->getSanitizedName(), 'message' => $soapHeaderMessage)); } return null; }
/** * @param string $elementName * @param string $value * @return DOMElement */ private function createElement($elementName, $value = '') { return XMLAttributeHelper::forDOM($this->DOMDocument)->createElement($elementName, $value); }
/** * @param DOMDocument $DOMDocument * @param Node $node * @param DOMElement|null $sequenceElement * @param string $soapVersion * @return DOMElement[] */ private function generateParameters(DOMDocument $DOMDocument, Node $node, DOMElement $sequenceElement = null, $soapVersion) { $result = []; if ($sequenceElement) { $attributes = $this->attributes($node); $elementPartElement = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:element', $attributes); $sequenceElement->appendChild($elementPartElement); } if ($node->isArray()) { $complexTypeElement = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:complexType', ['name' => $node->getNameForArray()]); $complexContentElement = XMLAttributeHelper::forDOM($DOMDocument)->createElement('xsd:complexContent'); $restrictionElement = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:restriction', ['base' => 'soapenc:Array']); $type = $node->isObject() ? 'ns:' . $node->getNameForObject() . '[]' : 'xsd:' . $node->getType() . '[]'; $attributeElement = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:attribute', ['ref' => 'soapenc:arrayType', $soapVersion . ':arrayType' => $type]); $restrictionElement->appendChild($attributeElement); $complexContentElement->appendChild($restrictionElement); $complexTypeElement->appendChild($complexContentElement); $result[] = $complexTypeElement; } if ($node->isObject()) { $name = $node->getNameForObject(); $element = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:element', ['name' => $name, 'nillable' => 'true', 'type' => 'ns:' . $name]); $result[] = $element; $complexTypeElement = XMLAttributeHelper::forDOM($DOMDocument)->createElementWithAttributes('xsd:complexType', ['name' => $node->getNameForObject()]); $sequenceElement = XMLAttributeHelper::forDOM($DOMDocument)->createElement('xsd:sequence'); $complexTypeElement->appendChild($sequenceElement); $result[] = $complexTypeElement; foreach ($node->getElements() as $nodeElement) { $tmp = $this->generateParameters($DOMDocument, $nodeElement, $sequenceElement, $soapVersion); $result = array_merge($result, $tmp); } } return $result; }