I’m trying to figure out how to generate a multilevel XML using Laminas SOAP Autodiscover but I’m unable to do it.
I read the documentation but can not find a way to do it. Here’s the link WSDL AutoDiscovery - laminas-soap - Laminas Docs
Here is the output of what I need:
<Header>
<item1>?</item1>
<item2>?</item2>
<Line>
<item3>?</item3>
<item4>?</item4>
</Line>
</Header>
But I can not find a way to tell the AutoDiscover that a head (Header tag, that will contain a few tags and a child tag called Line). The only WSDL that is generated is by removing the Header and the Line from the function.
Class Soap
{
public function test($item1,$item2,$item3,$item4) {
return;
}
}
$serverUrl = "http://localhost/api.php";
$options = [
'uri' => $serverUrl,
];
$server = new \Laminas\Soap\Server(null, $options);
if (isset($_GET['wsdl'])) {
$soapAutoDiscover = new \Laminas\Soap\AutoDiscover(new \Laminas\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
$soapAutoDiscover->setBindingStyle(array('style' => 'document'));
$soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal'));
$soapAutoDiscover->setClass('Soap');
$soapAutoDiscover->setUri($serverUrl);
header("Content-Type: text/xml");
echo $soapAutoDiscover->generate()->toXml();
} else {
$soap = new \Laminas\Soap\Server($serverUrl . '?wsdl');
$soap->setObject(new \Laminas\Soap\Server\DocumentLiteralWrapper(new Soap()));
$soap->handle();
}
This will output just an WSDL with the four items:
<xsd:element name="test">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item1" type="xsd:anyType"/>
<xsd:element name="item2" type="xsd:anyType"/>
<xsd:element name="item3" type="xsd:anyType"/>
<xsd:element name="item4" type="xsd:anyType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Any help will be appreciated.