⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webservice.htc

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 HTC
📖 第 1 页 / 共 5 页
字号:
    var nBinding = xmlSdl.selectNodes(nsq + "binding");
    var nService = xmlSdl.selectNodes(nsq + "service");
    var nTypes   = xmlSdl.selectNodes(nsq + "types");

    if (nMsgs.length == 0)
    {
        nMsgs = xmlSdl.selectNodes("message");
        nsqMsg = "";
    }
    if (nPort.length == 0)
    {
        nPort = xmlSdl.selectNodes("portType");
        nsqPort = "";
    }
    if (nBinding.length == 0)
    {
        nBinding = xmlSdl.selectNodes("binding");
        nsqBinding = "";
    }
    if (nService.length == 0)
    {
        nService = xmlSdl.selectNodes("service");
        nsqService = "";
    }
    if (nTypes.length == 0)
    {
        nTypes = xmlSdl.selectNodes("types");
        nsqTypes = "";
    }

    var aMsgs    = new Array();
    var aPort    = new Array();
    var aBinding = new Array();

    oS.targetns = getAttrib(xmlSdl, "targetNamespace");
    oS.ns["xsd"] = "http://www.w3.org/2001/XMLSchema";
    oS.schemas = new Array();
    oS.msgs = aMsgs;
    oS.refs = new Array();
    oS.exts = new Array();
    for (var i = 0; i < xmlSdl.attributes.length; i++)
    {
        var oAtt = xmlSdl.attributes.item(i);
        if (oAtt.name == "xmlns")
            continue;
        var ii = oAtt.name.indexOf("xmlns:");
        if (ii != 0)
            continue;
        var nsn = oAtt.name.substring(6, oAtt.name.length);
        if (oS.ns[nsn] != null && nsn != "xsd")
            continue;
        oS.ns[nsn] = oAtt.value;
        oS.nsalias[oAtt.value] = nsn;
    }
    oS.qlt = new Array();
    oS.qlt["soapenc"] = "http://schemas.xmlsoap.org/soap/encoding/";
    oS.qlt["wsdl"] = "http://schemas.xmlsoap.org/wsdl/";
    oS.qlt["soap"] = "http://schemas.xmlsoap.org/wsdl/soap/";
    oS.qlt["SOAP-ENV"] = 'http://schemas.xmlsoap.org/soap/envelope/';
    for (var x in oS.qlt)
    {
        if (oS.nsalias[oS.qlt[x]] != null)
        {
            oS.qlt[x] = oS.nsalias[oS.qlt[x]];
            continue;
        }
        oS.ns[x] = oS.qlt[x];
        oS.nsalias[oS.qlt[x]] = x;
        oS.qlt[x] = x;
    }

    if (oS.ns["xsi"] == null) 
        oS.ns["xsi"] = oS.ns["xsd"] == xsd99 ? xsi99 : xsi01;

    for (var i = 0; i < nTypes.length; i ++)
        parseSchemas(oS, nTypes[i].childNodes);

    //
    // resolve cross refs
    //
    
    for (var x in oS.refs)
    {
        var q = getQualifier(x);
        var nsUri = oS.ns[q];
        var oschm = oS.schemas[nsUri];
        if (oschm == null)
            continue;
        var ot = oschm.elems[getBaseName(x)];
        oS.refs[x][ot.name] = ot;
    }

    //
    // resolve inheritance
    //

    for (var i in oS.exts)
        expBase(oS, oS.exts, oS.exts[i]);

    for (var i = 0; i < nMsgs.length; i++)
    {
        var sName = getAttrib(nMsgs[i], 'name');
        aMsgs[sName] = new Object();
        var ps = nMsgs[i].selectNodes(nsqMsg + "part");
        aMsgs[sName].args = new Array();

        for (var j = 0; j < ps.length; j ++)
        {
            var ap = new Object();
            ap.name = getAttrib(ps[j], "name");
            ap.type = getAttrib(ps[j], "type");
            ap.elem = getAttrib(ps[j], "element");
            if (ap.elem != null)
            {
                ap.ns = getQualifier(ap.elem);
                ap.elem = getBaseName(ap.elem);
            }
            if (ap.type != null)
            {
                ap.ns = getQualifier(ap.type);
                ap.type = getBaseName(ap.type);
            }
            ap.ns = getUniqueNsq(oS, ps[j], ap.ns);
            if (ap.type == "anyType" && oS.ns[ap.ns] == oS.ns["xsd"])
                ap.type = "string"; // note: only string is allowed for anyType
            aMsgs[sName].args[ap.name] = ap;
        }
        aMsgs[sName].argl = ps.length;
    }

    for (var i = 0; i < nPort.length; i++)
    {
        var sName = getAttrib(nPort[i], "name");
        aPort[sName] = new Object();
        
        var nops = nPort[i].selectNodes(nsqPort + "operation");

        var oops = new Array();
        aPort[sName].ops = oops;
        for (var j = 0; j < nops.length; j++)
        {
            var sOpName = getAttrib(nops[j], "name");
            var nInputs = nops[j].selectNodes(nsqPort + "input");
            var mInput = null;
            if (nInputs.length > 0)
            {
                var s = getAttrib(nInputs[0], "message");
                var sMsgName = getBaseName(s);
                var sNS = getQualifier(s);
                if (oops[sOpName] == null)
                    oops[sOpName] = new Array();
                var sin = getAttrib(nInputs[0], "name");
                if (sin != null)
                    oops[sOpName][sin] = aMsgs[sMsgName];
                else
                    oops[sOpName][sOpName] = aMsgs[sMsgName];
                if (aMsgs[sMsgName] == null)
                    break;
                aMsgs[sMsgName].opname = sOpName;
                mInput = aMsgs[sMsgName];
                var firstArg = get1stAryItem(mInput.args);
                //
                // as jscript is not strongly typed
                // we can't know if the encoding is wrapped/bare
                // just using type matching.
                // However, we can still make the distinction, if wsdl
                // uses method name as type/elem name for wrapped case.
                // WARNING, if wsdl doesn't follow this rule, we can no longer
                // support wrapped encoding
                //
                if (sin != null)
                    sOpName = sin;
                mInput.fWrapped = mInput.argl == 1 && firstArg != null
                    && (    firstArg.type == sOpName
                        ||  firstArg.elem == sOpName
                        ||  "parameters"  == firstArg.name.toLowerCase());
            }
            var nOutputs = nops[j].selectNodes(nsqPort + "output");
            if (nOutputs.length > 0)
            {
                var s = getAttrib(nOutputs[0], "message");
                var sMsgName = getBaseName(s);
                var sSoapName = aMsgs[sMsgName].soapName;
                if (sSoapName == null)
                    aPort[sName].ops[sMsgName] = aMsgs[sMsgName];
                else
                {
                    aPort[sName].ops[sSoapName] = aMsgs[sMsgName];
                    aMsgs[sSoapName] = aMsgs[sMsgName];
                }
                if (mInput != null)
                    mInput.response = aMsgs[sMsgName];
                
            }
            mInput.fOneWay = nOutputs.length == 0;
        }
    }

    for (var i = 0; i < nBinding.length; i++)
    {
        var osoapb = nBinding[i].selectNodes("soap:binding");
        if (osoapb == null || osoapb.length == 0)
            continue;

        var sStyle= getAttrib(osoapb[0], "style");

        var sName = getAttrib(nBinding[i], "name");
        aBinding[sName] = new Object();
        var stype = getBaseName(getAttrib(nBinding[i], "type"));
        aBinding[sName].msgs = aPort[stype].ops;

        var nops = nBinding[i].selectNodes(nsqBinding + "operation");

        for (var j = 0; j < nops.length; j++)
        {
            var sOpName = getAttrib(nops[j], "name");
            var input = nops[j].selectSingleNode(nsqBinding + "input");
            if (input == null)
                continue;
            var sin = getAttrib(input, "name");
            if (sin == null)
                sin = sOpName;

            var oM = aBinding[sName].msgs[sOpName][sin];
            if (oM == null)
                continue;

            var nsoapops = nops[j].selectNodes("soap:operation");
            if (nsoapops.length == 0)
                continue;
            var sOpStyle= getAttrib(nsoapops[0], "style");
            oM.soapAction = getAttrib(nsoapops[0], "soapAction");
            var nsoapbody = nops[j].selectNodes(nsqBinding + "input/soap:body");
            if (nsoapbody.length > 0)
            {
                oM.ns = getAttrib(nsoapbody[0], "namespace");
                oM.es = getAttrib(nsoapbody[0], "encodingStyle");
                var sUs = getAttrib(nsoapbody[0], "use");
                oM.fLiteral = (sUs != null && sUs.toLowerCase() == 'literal');
            }
            var nheadIn = nops[j].selectNodes(nsqBinding + "input/soap:header");
            oM.hdrsIn = new Array();
            for (var k = 0; k < nheadIn.length; k ++)
                oM.hdrsIn[k] = parseSoapHeader(oS, nheadIn[k])
            var nheadOut = nops[j].selectNodes(nsqBinding+"output/soap:header");
            oM.hdrsOut = new Array();
            for (var k = 0; k < nheadOut.length; k ++)
                oM.hdrsOut[k] = parseSoapHeader(oS, nheadOut[k])
            if (sOpStyle != null)
                oM.fRpc = sOpStyle.toLowerCase()=='rpc';
            else
                oM.fRpc=(sStyle !=null && sStyle.toLowerCase()=='rpc');
        }
    }

    oS.soapPort = new Array();
    oS.headers  = new Array();
    if (nService.length == 0)
    {
        oS.defPortName = "defaultPort";
        var aPort = new Object();
        oS.soapPort[oS.defPortName] = aPort;
        aPort.location = null;
        var firstBind = get1stAryItem(aBinding);
        aPort.msgs = firstBind == null ? (new Array()) : firstBind.msgs;
        return;
    }

    var nports = nService[0].selectNodes(nsqService + "port");
    for (var j = 0; j < nports.length; j++)
    {
        var oAddress = nports[j].selectNodes("soap:address");
        if (oAddress.length == 0)
            continue;
        var oSOAPHdr = nports[j].selectNodes("soap:header");
        for (var k = 0; k < oSOAPHdr.length; k ++)
            oS.headers[k] = parseSoapHeader(oS, oSOAPHdr[k]);
        oPort = new Object();
        oPort.location = getAttrib(oAddress[0], "location");
        var b = aBinding[getBaseName(getAttrib(nports[j], "binding"))];
        if (b == null)
            continue
        oPort.msgs = b.msgs;
        var szname = getAttrib(nports[j], "name");
        oS.soapPort[szname] = oPort;
        if (oS.defPortName == null)
            oS.defPortName = szname;
    }
}

function ensureXmlHttp(fAsync, oS)
{
    var oXmlHttp = null;
    var fCreate = fAsync ? oS.aXmlHttp == null : oS.sXmlHttp == null;
    if (!fCreate && oS.fSeq)
    {
        oXmlHttp = fAsync ? oS.aXmlHttp : oS.sXmlHttp;
        oXmlHttp.fFree = false;
        return oXmlHttp;
    }
    for (var i = 0; i < _aXmlHttp.length; i++)
        if (_aXmlHttp[i].fFree)
        {
            _aXmlHttp[i].fFree = false;
            oXmlHttp = _aXmlHttp[i];
            break;
        }
    if (oXmlHttp == null)
    {
        var xmlHttp;
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
            return null;
        }
        var oXmlHttp = new Object();
        oXmlHttp.fFree = false;
        oXmlHttp.xmlHttp = xmlHttp;
        _aXmlHttp[_aXmlHttp.length] = oXmlHttp;
    }
    if (!oS.fSeq)
        return oXmlHttp;
    if (fAsync)
        oS.aXmlHttp = oXmlHttp;
    else
        oS.sXmlHttp = oXmlHttp;
    return oXmlHttp;
}

function encodeHeader(oS, oM, oCall)
{
    var co = oCall.co;
    var sh = co.SOAPHeader == null ? oS.SOAPHeader : co.SOAPHeader;
    if (sh == null)
        return "";
    var ht = (oM.hdrsIn == null) ? oS.headers : oM.hdrsIn;
    var szHeader = "";
    if (typeof sh == 'string')
        szHeader = sh;
    else if (typeof sh == 'object' && sh.xml != null)
        szHeader = sh.xml;
    else if (ht.length != 0)
    {
        // fixup fir VB
        if (typeof(sh) == "unknown")
            sh = vbArrayToJs(sh, 1);

        //
        // make a fake method
           
        oM1 = new Object();
        oM1.opname = null;      // Header doesn't have a opname
        oM1.ns = oM.ns;
        oM1.fRpc = oM.fRpc;
        oM1.fWrapped = false;   // header is never wrapped
        // we assume that SOAP actor is omitted, the receipient is final
        // and mustunderstand is false
        // the user will need to construct his/her own header if needed
        // we will assume all headers will be encoded the same way
        for (var i = 0; i < ht.length; i++)
        {
            if (sh[i] == null)
            {
                if (ht[i].fRequired)
                    return returnError(oCall, 9);
                continue;
            }
            oM1.fLiteral = ht[i].fLiteral;
            var ta = new Array();
            ta[ht[i].type.name] = ht[i].type;
            var va = new Array();
            va[0] = sh[i];
            szHeader += encodeArgs(oS, oM1, ta, va, 0, false);
        }
    }
    var soapenvns = oS.qlt["SOAP-ENV"];
    return '<'+soapenvns+':Header>' + szHeader +"</"+soapenvns+":Header>\n";
}

function _invoke(oCall)
{
    var szS = oCall.service;
    var oS = _sdl[szS];
    var co = oCall.co;

    if (oS == null)
    {
        return postError(oCall, 1);
    }
    if (co.portName == null)
        co.portName = oS.defPortName;
    if (oS.soapPort[co.portName] == null)
    {
        callNext(oS);
        return returnError(oCall, 8);
    }

    var oXmlHttp = ensureXmlHttp(co.async, oS);
    if (oXmlHttp == null)
        return returnError(oCall, 6);

    var args = co.params == null ? oCall.args : co.params;
    var cb = oCall.cb;

    var j = cb == null ? 1 : 2;
    j = co.params == null ? j : 0;
    var oM = getMsg(szS, co, args, j);
    var szParams = null;

    if (oM != null)
    {
        szParams = encodeArgs(oS, oM, oM.args, args, j, co.params != null);
    }
    if (szParams == null)
    {
        callNext(oS);
        return returnError(oCall, 0);
    }

    oCall.oM = oM;

    if (showProgress == "true" || showProgress == true)
        fnShowProgress();

    var oP = oS.soapPort[co.portName];
    var loc = co.endpoint == null ? oP.location : co.endpoint;
    if (loc == null)
    {
        callNext(oS);
        return returnError(oCall, 8);
    }
    try
    {
        if (co.userName == null)
            oXmlHttp.xmlHttp.open("POST", loc, co.async);
        else
            oXmlHttp.xmlHttp.open("POST", loc, co.async,
                        co.userName, co.password == null ? "" : co.password);
    }
    catch (e)
    {
        callNext(oS);
        return returnError(oCall, 5);
    }
    var szAction = oM.soapAction;
    if (szAction != null && szAction.length > 0)
        oXmlHttp.xmlHttp.setRequestHeader("SOAPAction", '"'+szAction+'"');
    oXmlHttp.xmlHttp.setRequestHeader("Content-Type",
                                    'text/xml; charset="UTF-8"');

    var sNS = ' xmlns=""';

    for (var ns in oS.ns)
    {
        var nsuri = oS.ns[ns];
        if (ns == "" || nsuri == "")
            continue;
        sNS +=  " xmlns:" + ns + '="' + nsuri + '"';
    }

    var szHeader = encodeHeader(oS, oM, oCall);

    var soapenvns = oS.qlt["SOAP-ENV"];
    var soapes = (oM.es==null?'':(' '+soapenvns+':encodingStyle="'+oM.es+'"'));
    var szPayload = "<?xml version='1.0' encoding='utf-8'?>\n<"
            + soapenvns + ":Envelope"
            + soapes
            + sNS + ">\n"
            + szHeader
            + '<' + soapenvns + ':Body>'
            + szParams + "</" + soapenvns + ":Body>\n"
            + "</" + soapenvns + ":Envelope>\n";

    if (co.async)
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -