protected function addTypes(DomDocument $doc, DomElement $root) { $types = $doc->createElementNS(self::SCHEMA_WSDL, 'types'); $root->appendChild($types); $el = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'schema'); $el->setAttribute('attributeFormDefault', 'qualified'); $el->setAttribute('elementFormDefault', 'qualified'); $el->setAttribute('targetNamespace', $this->ns); $types->appendChild($el); foreach ($this->complexTypes as $name => $data) { if ($name == 'mixed') { continue; } $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType'); $ct->setAttribute('name', $name); $all = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence'); foreach ($data as $prop) { $p = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $p->setAttribute('name', $prop['name']); $prefix = $root->lookupPrefix($this->types[$prop['type']]['ns']); $p->setAttribute('type', "{$prefix}:" . $this->types[$prop['type']]['name']); $all->appendChild($p); } $ct->appendChild($all); $el->appendChild($ct); } $nsPrefix = $root->lookupPrefix($this->ns); // Add message types foreach ($this->operations as $name => $params) { foreach (array('input' => '', 'output' => 'Response') as $type => $postfix) { $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $fullName = "{$name}" . ucfirst($postfix); $ce->setAttribute('name', $fullName); $ce->setAttribute('type', "{$nsPrefix}:{$fullName}"); $el->appendChild($ce); $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType'); $ct->setAttribute('name', $fullName); $ctseq = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence'); $ct->appendChild($ctseq); foreach ($params[$type] as $param) { $pare = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $pare->setAttribute('name', $param['name']); $prefix = $root->lookupPrefix($this->types[$param['type']]['ns']); $pare->setAttribute('type', "{$prefix}:" . $this->types[$param['type']]['name']); $ctseq->appendChild($pare); } $el->appendChild($ct); } } // Add fault elements foreach ($this->faults as $faultType) { $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $ce->setAttribute('name', $faultType); $prefix = $root->lookupPrefix($this->types[$faultType]['ns']); $ce->setAttribute('type', $prefix . ':' . $faultType); $el->appendChild($ce); $ce = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $ce->setAttribute('name', $faultType . 'Fault'); $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType'); $seq = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'sequence'); $elFault = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'element'); $elFault->setAttribute('ref', $prefix . ':' . $faultType); $seq->appendChild($elFault); $ct->appendChild($seq); $ce->appendChild($ct); $el->appendChild($ce); } }
protected function addTypes(DomDocument $doc, DomElement $root) { $types = $doc->createElementNS(self::SCHEMA_WSDL, 'types'); $root->appendChild($types); $el = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'schema'); $types->appendChild($el); /* BEGIN: crutch */ $ct = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexType'); $el->appendChild($ct); $ct->setAttribute('name', 'array'); $cc = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'complexContent'); $ct->appendChild($cc); $restriction = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'restriction'); $cc->appendChild($restriction); $restriction->setAttribute('base', 'soapenc:array'); $attribute = $doc->createElementNS(self::SOAP_XML_SCHEMA_VERSION, 'attribute'); $restriction->appendChild($attribute); $attribute->setAttribute('ref', 'soapenc:arrayType'); $attribute->setAttributeNS(self::SCHEMA_WSDL, 'arrayType', 'tns:mixed[]'); /* END: crutch */ foreach ($this->complexTypes as $name => $data) { $ct = $doc->createElementNS(self::SCHEMA_WSDL, 'complexType'); $ct->setAttribute('name', $name); $all = $doc->createElementNS(self::SCHEMA_WSDL, 'all'); foreach ($data as $prop) { $p = $doc->createElementNS(self::SCHEMA_WSDL, 'element'); $p->setAttribute('name', $prop['name']); $p->setAttribute('name', $prop['name']); $prefix = $root->lookupPrefix($this->types[$prop['type']]['ns']); $p->setAttribute('type', "{$prefix}:" . $this->types[$prop['type']]['name']); $all->appendChild($p); } $ct->appendChild($all); $el->appendChild($ct); } }