|
9 | 9 | use Soap\Wsdl\Exception\UnloadableWsdlException; |
10 | 10 | use Soap\Wsdl\Loader\Context\FlatteningContext; |
11 | 11 | use Soap\Wsdl\Uri\IncludePathBuilder; |
| 12 | +use Soap\Xml\Xmlns; |
12 | 13 | use Soap\Xml\Xpath\WsdlPreset; |
13 | 14 | use VeeWee\Xml\Dom\Configurator\Configurator; |
14 | 15 | use VeeWee\Xml\Dom\Document; |
15 | 16 | use VeeWee\Xml\Exception\RuntimeException; |
16 | 17 | use function VeeWee\Xml\Dom\Locator\document_element; |
17 | 18 | use function VeeWee\Xml\Dom\Locator\Node\children; |
| 19 | +use function VeeWee\Xml\Dom\Manipulator\Node\append_external_node; |
18 | 20 | use function VeeWee\Xml\Dom\Manipulator\Node\remove; |
19 | 21 | use function VeeWee\Xml\Dom\Manipulator\Node\replace_by_external_nodes; |
20 | 22 |
|
@@ -66,11 +68,34 @@ private function importWsdlImportElement(DOMElement $import): void |
66 | 68 | } |
67 | 69 |
|
68 | 70 | $imported = Document::fromXmlString($result); |
69 | | - $definitions = $imported->map(document_element()); |
| 71 | + |
| 72 | + // A wsdl:import can be either a WSDL or an XSD file: |
| 73 | + match ($imported->locateDocumentElement()->namespaceURI) { |
| 74 | + Xmlns::xsd()->value() => $this->importXsdPart($import, $imported), |
| 75 | + default => $this->importWsdlPart($import, $imported), |
| 76 | + }; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * @throws RuntimeException |
| 81 | + */ |
| 82 | + private function importWsdlPart(DOMElement $importElement, Document $importedDocument): void |
| 83 | + { |
| 84 | + $definitions = $importedDocument->map(document_element()); |
70 | 85 |
|
71 | 86 | replace_by_external_nodes( |
72 | | - $import, |
| 87 | + $importElement, |
73 | 88 | children($definitions) |
74 | 89 | ); |
75 | 90 | } |
| 91 | + |
| 92 | + /** |
| 93 | + * @throws RuntimeException |
| 94 | + */ |
| 95 | + private function importXsdPart(DOMElement $importElement, Document $importedDocument): void |
| 96 | + { |
| 97 | + $types = $this->context->types(); |
| 98 | + remove($importElement); |
| 99 | + append_external_node($types, $importedDocument->locateDocumentElement()); |
| 100 | + } |
76 | 101 | } |
0 commit comments