- Модуль: webservice
- Путь к файлу: ~/bitrix/modules/webservice/classes/general/wsdl/wsdlcreator.php
- Класс: CWSDLCreator
- Вызов: CWSDLCreator::createWSDL
function createWSDL ()
{
global $xsd_simple_type;
if (!$this->classes or !count($this->classes)) return 0;
foreach ($this->classes as $class=>$methods) {
$pbs = array();
ksort($methods);
foreach ($methods as $method=>$components)
{
if ($components["type"] == "public") {
$this->__createMessage($method, $components["output"], $components["input"]);
$pbs[$class][$method]["documentation"] = $components["description"];
$pbs[$class][$method]["input"] = $components["input"];
$pbs[$class][$method]["output"] = $components["output"];
}
}
$this->__createPortType($pbs);
$this->__createBinding($pbs);
$this->__createService($pbs);
//AddMessage2Log(mydump($this->portTypes));
}
//echo ''; print_r($this); echo '
';
// add types
if (is_array($this->typensDefined) && count($this->typensDefined) > 0) {
$types = new CXMLCreator("wsdl:types");
$xsdSchema = new CXMLCreator("xsd:schema");
$xsdSchema->setAttribute("elementFormDefault", "qualified");
$xsdSchema->setAttribute("targetNamespace", $this->targetNamespace);
foreach ($this->typensDefined as $typensDefined) {
$xsdtype = "element";
if (isset($this->typensXSDType[$typensDefined])) $xsdtype = "type";
if ($xsdtype == "element") {
$elroot = new CXMLCreator("xsd:element");
$elroot->setAttribute("name", $typensDefined);
}
$complexType = new CXMLCreator("xsd:complexType");
if ($xsdtype == "type")
$complexType->setAttribute("name", $typensDefined);
$all = new CXMLCreator("xsd:sequence");
if (isset($this->typensVars[$typensDefined])
and is_array($this->typensVars[$typensDefined])) {
//commented by Sigurd;
//ksort($this->typensVars[$typensDefined]);
foreach ($this->typensVars[$typensDefined] as $varName=>$varType) {
// check minOccurs|maxOccurs here!
$element = new CXMLCreator("xsd:element");
$element->setAttribute("minOccurs", 0);
if (is_array($varType) and isset($varType["maxOccurs"]))
$element->setAttribute("maxOccurs", $varType["maxOccurs"]);
else
$element->setAttribute("maxOccurs", 1);
if (is_array($varType) and isset($varType["nillable"]))
$element->setAttribute("nillable", $varType["nillable"]);
$element->setAttribute("name", $varName);
if (is_array($varType)) $varType = $varType["varType"];
if ($varType == 'any')
{
$any = new CXMLCreator('xsd:any');
$sequence = new CXMLCreator('xsd:sequence');
$sequence->addChild($any);
$element->addChild($sequence);
$complexType->setAttribute('mixed', "true");
}
else
{
$varType = isset($xsd_simple_type[$varType]) ? "xsd:".$xsd_simple_type[$varType] : "tns:".$varType;
$element->setAttribute("type", $varType);
}
$all->addChild($element);
}
}
$complexType->addChild($all);
if ($xsdtype == "element") {
$elroot->addChild($complexType);
$xsdSchema->addChild($elroot);
} else {
$xsdSchema->addChild($complexType);
}
}
$types->addChild($xsdSchema);
$this->WSDLXML->addChild($types);
}
// adding messages
foreach ($this->messages as $message) {
$this->WSDLXML->addChild($message);
}
// adding port types
foreach ($this->portTypes as $portType) {
$this->WSDLXML->addChild($portType);
}
// adding bindings
foreach ($this->bindings as $binding) {
$this->WSDLXML->addChild($binding);
}
// adding services
$s = new CXMLCreator("wsdl:service");
$s->setAttribute("name", $this->serviceName);
foreach ($this->services as $service) {
$s->addChild($service);
}
$this->WSDLXML->addChild($s);
$this->WSDL = "n";
//$this->WSDL .= "n";
$this->WSDL .= $this->WSDLXML->getXML();
}