src/XSD2PHP/src/com/mikebevz/xsd2php/Wsdl.php
public function addMessages()
    {
        $methods = $this->getClassMethods();
        $messages = array();
        foreach ($methods as $method) {
            $data = $this->getMethodIO($method->name);

            $input = false;
            $output = false;
            // Add inputs if any
            if (array_key_exists("params", $data)) {
                array_push($messages, array('name' => $method->name.$this->requestSuffix, 'refType' => 'element',
                 'content' => array($method->name.$this->requestSuffix => $this->targetNsPrefix.":".$method->name)));
            }

            // Add outputs if any
            if (array_key_exists("return", $data)) {
                array_push($messages, array('name' => $method->name.$this->responseSuffix, 'refType' => 'element',
                 'content' => array($method->name.$this->responseSuffix => $this->targetNsPrefix.":".$method->name.$this->responseSuffix)));
            }
        }

        if (empty($messages)) {
            throw new \RuntimeException($method->name." does not have any input or output");
        }



        if (!is_array($messages)) {
            throw new \RuntimeException("Argument is not array");
        }

        foreach ($messages as $msg) {
            if ($msg['refType'] == 'type') {
                $this->wsdl->addMessage($msg['name'], $msg['content']);
            } elseif ($msg['refType'] == 'element') {
                $dom = $this->wsdl->toDomDocument();
                $msgEl = $dom->createElement('message');
                $msgNameAt = $dom->createAttribute('name');
                $msgNameTxtNode = $dom->createTextNode($msg['name']);
                $msgNameAt->appendChild($msgNameTxtNode);
                $msgEl->appendChild($msgNameAt);

                $partEl = $dom->createElement("part");
                $partNameAt = $dom->createAttribute("name");
                $partElAt = $dom->createAttribute('element');
                foreach ($msg['content'] as $name => $element) {
                    $partNameTxtNode = $dom->createTextNode($name);
                    $partNameAt->appendChild($partNameTxtNode);

                    $partElTxtNode = $dom->createTextNode($element);
                    $partElAt->appendChild($partElTxtNode);
                }
                $partEl->appendChild($partNameAt);
                $partEl->appendChild($partElAt);

                $msgEl->appendChild($partEl);

                $xpath = new \DOMXPath($dom);
                $query = "//*[local-name()='definitions']";
                $childs = $xpath->query($query);
                $childs->item(0)->appendChild($msgEl);
            } else {
                throw new \RuntimeException("refType only can be type or element");
            }
        }
    }
public function addMessages()
    {
        $methods = $this->getClassMethods();
        $messages = array();
        foreach ($methods as $method) {
            $data = $this->getMethodIO($method->name);

            $input = false;
            $output = false;
            // Add inputs if any
            if (array_key_exists("params", $data)) {
                array_push($messages, array('name' => $method->name.$this->requestSuffix, 'refType' => 'element',
                 'content' => array($method->name.$this->requestSuffix => $this->targetNsPrefix.":".$method->name)));
            }

            // Add outputs if any
            if (array_key_exists("return", $data)) {
                array_push($messages, array('name' => $method->name.$this->responseSuffix, 'refType' => 'element',
                 'content' => array($method->name.$this->responseSuffix => $this->targetNsPrefix.":".$method->name.$this->responseSuffix)));
            }
        }

        if (empty($messages)) {
            throw new \RuntimeException($method->name." does not have any input or output");
        }



        if (!is_array($messages)) {
            throw new \RuntimeException("Argument is not array");
        }

        foreach ($messages as $msg) {
            if ($msg['refType'] == 'type') {
                $this->wsdl->addMessage($msg['name'], $msg['content']);
            } elseif ($msg['refType'] == 'element') {
                $dom = $this->wsdl->toDomDocument();
                $msgEl = $dom->createElement('message');
                $msgNameAt = $dom->createAttribute('name');
                $msgNameTxtNode = $dom->createTextNode($msg['name']);
                $msgNameAt->appendChild($msgNameTxtNode);
                $msgEl->appendChild($msgNameAt);

                $partEl = $dom->createElement("part");
                $partNameAt = $dom->createAttribute("name");
                $partElAt = $dom->createAttribute('element');
                foreach ($msg['content'] as $name => $element) {
                    $partNameTxtNode = $dom->createTextNode($name);
                    $partNameAt->appendChild($partNameTxtNode);

                    $partElTxtNode = $dom->createTextNode($element);
                    $partElAt->appendChild($partElTxtNode);
                }
                $partEl->appendChild($partNameAt);
                $partEl->appendChild($partElAt);

                $msgEl->appendChild($partEl);

                $xpath = new \DOMXPath($dom);
                $query = "//*[local-name()='definitions']";
                $childs = $xpath->query($query);
                $childs->item(0)->appendChild($msgEl);
            } else {
                throw new \RuntimeException("refType only can be type or element");
            }
        }
    }
Add SOAP messages

@param array $messages Messages to add

@return void
@throws RuntimeException If method does not have any inputs/outputs
@throws RuntimeException If