Create a SimpleType element


I’m migrating an API based on nusoap and I want to know, how I can create “SimpleType” elements with Laminas?

First, I create a soap server with nusoap:

require_once __DIR__ . "/vendor/autoload.php";
require_once __DIR__ . "/vendor/econea/nusoap/src/nusoap.php";

$namespace = "Soap.Service";
$server = new soap_server();
$server->configureWSDL("mysoap", $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;

Then, I add the SimpleType’s. In this case, I need to create a SimpleType for only receive one of the array elements in a ComplexType:


Finally, I create the ComplexType’s where I need to use the SimpleType “tipoDocumento”:

        'tipoDocumento' => array('name' => 'tipoDocumento', 'type' => 'xsd:tipoDocumento'),
        'nombre' => array('name' => 'nombre', 'type' => 'xsd:string', 'use' => 'required'),
        'email' => array('name' => 'email', 'type' => 'xsd:string', 'minOccurs' => '0'),

This is the xml that I wanted:

<xsd:simpleType name="tipoDocumento">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="DNI"/>
        <xsd:enumeration value="LE"/>
        <xsd:enumeration value="LC"/>
        <xsd:enumeration value="CI"/>
        <xsd:enumeration value="PASSPORT"/>

<xsd:complexType name="persona">
        <xsd:element name="tipoDocumento" type="xsd:tipoDocumento"/>
        <xsd:element name="nombre" type="xsd:string" use="required"/>
        <xsd:element name="email" type="xsd:string" minOccurs="0" maxOccurs="2"/>