Ejemplo n.º 1
0
/**
 * Create WSDL DomDocument from given WSDL location.
 * If given WSDL is WSDL1.1 then it would be coverted to a WSDL2.0
 * @param string $wsdl_location
 * @return DomDocument $wsdl_dom DomDocument of WSDL2.0
 */
function wsf_get_wsdl_dom($wsdl_dom, $wsdl_location, &$is_wsdl_11, &$wsdl_11_dom, $streamctx)
{
    require_once 'wsf_wsdl_consts.php';
    $xslt_wsdl_20_dom = new DOMDocument();
    $xslt_11_to_20_dom = new DOMDocument();
    $xslt_wsdl_20_dom->preserveWhiteSpace = FALSE;
    $xslt_11_to_20_dom->preserveWhiteSpace = FALSE;
    $xslt = new XSLTProcessor();
    if ($wsdl_dom) {
        $child_list = $wsdl_dom->childNodes;
        foreach ($child_list as $child) {
            if ($child->nodeType != XML_ELEMENT_NODE) {
                continue;
            }
            if ($child->localName == WSF_DEFINITION) {
                /* first element local name is definitions, so this is a
                   version 1.1 WSDL */
                -($xslt_str = file_get_contents(WSF_WSDL1TO2_XSL_LOCATION, TRUE));
                $xslt_wsdl_20_dom->loadXML($xslt_str);
                $xslt->importStyleSheet($xslt_wsdl_20_dom);
                //clear out the wsdl imports
                $wsdl_dom = wsf_clear_wsdl_imports($wsdl_dom, $wsdl_location, $streamctx);
                $wsdl_dom = wsf_clear_xsd_imports($wsdl_dom, $wsdl_location, $streamctx);
                //$wsdl_dom->preserveWhiteSpace = FALSE;
                // we are serialized the dom to a string and convert it back as a string
                // to make sure we give xslt a fresh copy of dom tree
                $wsdl_str = $wsdl_dom->saveXML();
                $wsdl_dom->loadXML($wsdl_str);
                $xslt_11_to_20_str = $xslt->transformToXML($wsdl_dom);
                $xslt_11_to_20_dom->loadXML($xslt_11_to_20_str);
                $wsdl_11_dom = $wsdl_dom;
                $is_wsdl_11 = TRUE;
                return $xslt_11_to_20_dom;
            } else {
                if ($child->localName == WSF_DESCRIPTION) {
                    /* first element local name is description, so this is a
                       version 2.0 WSDL */
                    $is_wsdl_11 = FALSE;
                    return $wsdl_dom;
                } else {
                    /* echo "Not a valid WSDL"; */
                    return NULL;
                }
            }
        }
    } else {
        return NULL;
    }
}
Ejemplo n.º 2
0
/**
 * Function to write 'sig model' for a given wsdl   
 * $wsdl_location location of the WSDL
 * returns none
 */
function wsf_wsdl2sig($wsdl_location)
{
    require_once 'dynamic_invocation/wsf_wsdl_consts.php';
    require_once 'dynamic_invocation/wsf_wsdl_util.php';
    global $written_classes;
    global $operations;
    $code = "";
    $wsdl_dom = new DomDocument();
    $sig_model_dom = new DOMDocument();
    $xslt_location = "./xslt/";
    $sig_model_dom->preserveWhiteSpace = false;
    $wsdl_dom->preserveWhiteSpace = false;
    if (!$wsdl_location) {
        echo "WSDL is not found";
        return NULL;
    }
    $is_multiple_interfaces = FALSE;
    // load WSDL as DOM
    if (!$wsdl_dom->load($wsdl_location)) {
        echo "WSDL could not be loaded.";
        return NULL;
    }
    $wsdl_dom->preserveWhiteSpace = false;
    // changing code for processing mutiple port types in wsdl 1.1
    $is_multiple_interfaces = wsf_is_mutiple_port_types($wsdl_dom);
    if ($is_multiple_interfaces == FALSE) {
        $wsdl_dom = wsf_get_wsdl_dom($wsdl_dom, $xslt_location);
        if (!$wsdl_dom) {
            echo "Error creating WSDL DOM document";
            return NULL;
        }
        $wsdl_dom = wsf_clear_wsdl_imports($wsdl_dom);
        $sig_model_dom = wsf_get_sig_model_dom($wsdl_dom, $xslt_location);
    } else {
        $wsdl_dom = wsf_clear_wsdl_imports($wsdl_dom);
        $wsdl_dom = wsf_get_wsdl_dom($wsdl_dom, $xslt_location);
        $sig_model_dom = wsf_process_multiple_interfaces($wsdl_dom, $sig_model_dom, $xslt_location);
    }
    if (!$sig_model_dom) {
        echo "Error creating intermediate service operations signature model";
        return NULL;
    }
    echo $sig_model_dom->saveXML();
}