Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @param string $wsdl Filename, URI or XML for the WSDL
  * @param string $output Output file name, default: null
  */
 public static function parse($wsdl, $output = null)
 {
     self::$wsdl = Zend_Soap_Wsdl_Parser::parse($wsdl);
     self::$php_code = self::generatePhp();
     if (!is_null($output) && is_writable($output)) {
         file_put_contents($output);
     }
     return self::$php_code;
 }
Ejemplo n.º 2
0
    /**
     * Parse a WSDL document into a generic object
     *
     * @param string|file $wsdl The WSDL document or a filename for the WSDL document to parse
     * @return Zend_Soap_Wsdl_Parser_Result The contents of the WSDL file
     */
    public static function parse($wsdl)
    {
        if (strpos($wsdl, '<') === false) {
            $wsdl_result = new Zend_Soap_Wsdl_Parser_Result($wsdl);
            $wsdl = file_get_contents($wsdl);
        } else {
            $tmp = new tempnam(ini_get('upload_tmp_dir'), 'ZF_Temp_');
            file_put_contents($tmp, $wsdl);
            $wsdl_result = new Zend_Soap_Wsdl_Parser_Result($tmp);
        }

        self::$xml = simplexml_load_string($wsdl);
        
        /* This is done so that we have a known prefix to the WSDL elements
            for XPath queries */

        self::$xml['xmlns:zfwsdl'] = 'http://schemas.xmlsoap.org/wsdl/';

        self::$xml = simplexml_load_string(self::$xml->asXML());

        if (isset(self::$xml->documentation)) {
            $wsdl_result->documentation = trim(self::$xml->documentation);
        }
        if (!isset(self::$xml['name'])) {
            $wsdl_result->name = null;
        } else {
            $wsdl_result->name = (string) self::$xml['name'];
        }

        foreach (self::$xml->binding->operation as $operation) {
            $name = (string) $operation['name'];
            $wsdl_result->operations[$name] = array();
            $wsdl_result->operations[$name]['input'] = self::getOperationInputs($name);
            $wsdl_result->operations[$name]['output'] = self::getOperationOutput($name);
            $wsdl_result->operations[$name]['documentation'] = self::getDocs($name);
        }

        $wsdl_result->portType = (string) self::$xml->portType['name'];
        $wsdl_result->binding = (string) self::$xml->binding['name'];
        $wsdl_result->service['name'] = (string) self::$xml->service['name'];
        $wsdl_result->service['address'] = (string) self::$xml->service->port->children('http://schemas.xmlsoap.org/wsdl/soap/')->attributes();
        $wsdl_result->targetNamespace = (string) self::$xml['targetNamespace'];

        return $wsdl_result;
    }
Ejemplo n.º 3
0
 public function testParseExampleWsdlWithDocumentationBlocks()
 {
     $dom = new DOMDocument();
     $dom->loadXml(file_get_contents(dirname(__FILE__) . "/../_files/wsdl_documentation.wsdl"));
     $parser = new Zend_Soap_Wsdl_Parser($dom);
     $result = $parser->parse();
 }