📄 webserviced.htc
字号:
continue;
case 'restriction' :
return parseComplexType(oS, oschm, o2, ssffx);
case 'all' :
return parseComplexType(oS, oschm, o1, ssffx);
}
continue;
case 'attribute' :
var soapns = oS.ns[oS.qlt["soap"]];
var wsdlns = oS.ns[oS.qlt["wsdl"]];
var at=o1.attributes.getQualifiedItem("arrayType", wsdlns);
if (at == null)
at=o1.attributes.getQualifiedItem("arrayType", soapns);
if (at == null)
{
if (ot == null)
{
ot = new Array();
ot[getAttrib(o1, "name")] = parseAttrib(o1);
}
continue;
}
var tn = getBaseName(at.value);
if (ot != null)
{
var oe = get1stAryItem(ot);
oe.fArray = true;
oe.sizeArray = new Array();
parseArrayType(oe.sizeArray,
tn.substring(tn.indexOf("[")+1, tn.length));
continue;
}
var oe = new Object();
var a = tn.split("[");
if (a.length < 2)
continue;
oe.ns = getQualifier(at.value);
oe.ns = getUniqueNsq(oS, o1, oe.ns);
oe.name = a[0];
oe.fArray = true;
oe.type = a[0];
if (oe.type == "anyType" && oS.ns[oe.ns] == oS.ns["xsd"])
oe.type = "string";
oe.sizeArray = new Array();
parseArrayType(oe.sizeArray,
tn.substring(tn.indexOf("[")+1, tn.length));
ot = new Array();
ot[a[0]] = oe;
continue;
}
}
return ot;
}
function parseAttrib(o)
{
var attrib = new Object();
attrib.fAttrib = true;
var st = getAttrib(o, "type");
if (st != null)
{
var a = st.split(":");
attrib.type = a.length > 1 ? a[1] : a[0];
attrib.ns = a.length > 1 ? a[0] : null;
}
attrib.fixed = getAttrib(o, "fixed");
attrib.name = getAttrib(o, "name");
attrib.allowed = getAttrib(o, "use") != "prohibited";
return attrib;
}
function parseElem(oS, oschm, o, ssffx)
{
var oe = new Object();
oe.name = getAttrib(o, "name");
var st = getAttrib(o, "type");
if (st == null)
st = getAttrib(o, "xsi:type");
var minOccurs = getAttrib(o, "minOccurs");
var maxOccurs = getAttrib(o, "maxOccurs");
oe.fArray = (maxOccurs != null && maxOccurs != "1");
if (st != null)
{
oe.type = getBaseName(st);
oe.ns = getQualifier(st);
if (oe.ns == '')
oe.ns = oschm.qdef;
if (oe.type == "anyType" && oS.ns[oe.ns] == oS.ns["xsd"])
oe.type = "string"; // note: only string is allowed for anyType
return oe;
}
oe.ns = oS.nsalias[oschm.uri];
if (typeof ssffx != 'undefined')
oe.type = ssffx + '_' + oe.name;
else
oe.type = oe.name;
var ct = parseType(oS, oschm, o.firstChild, ssffx);
oschm.types[oe.type] = ct;
return oe;
}
function parseSoapHeader(oS, o)
{
var hdrInfo = new Object();
hdrInfo.ns = getAttrib(o, "namespace");
hdrInfo.es = getAttrib(o, "encodingStyle");
var sUs = getAttrib(o, "use");
hdrInfo.fLiteral = (sUs != null && sUs.toLowerCase()=='literal');
var smsg = getAttrib(o, "message");
var amh = oS.msgs[getBaseName(smsg)];
var spart = getAttrib(o, "part");
hdrInfo.fRequired = getAttrib(o, "required") == "true";
hdrInfo.type = amh.args[getBaseName(spart)];
return hdrInfo;
}
//
// expand base types
// a[in] : derived type array
// t[in] : derived type for which we want base types to be expanded
//
function expBase(oS, a, t)
{
if (t.fExpanded)
return;
if (a[t.base] != null)
expBase(oS, a, a[t.base]);
t.fExpanded = true;
var oSchm = oS.schemas[t.nsuri];
var oSuper = oSchm.types[t.base];
if (oSuper == null || t.derivedType == null)
return;
for (var x in oSuper)
if (t.derivedType[x] == null)
t.derivedType[x] = oSuper[x];
}
function parseSchemas(oS, nSchemas)
{
for (var j = 0; j < nSchemas.length; j ++)
{
var schmUri = getAttrib(nSchemas[j], "targetNamespace");
if (oS.schemas[schmUri] == null)
{
var oSchm = new Object();
oSchm.uri = getAttrib(nSchemas[j], "targetNamespace");
oSchm.efd = getAttrib(nSchemas[j], "elementFormDefault");
oSchm.afd = getAttrib(nSchemas[j], "attributeFormDefault");
var nsdef = nSchemas[j].namespaceURI;
if (nsdef == null || nSchemas[j].prefix != '')
nsdef = oSchm.uri;
oSchm.qdef = oS.nsalias[nsdef];
if (oSchm.qdef == null)
{
oSchm.qdef = "";
oS.ns[oSchm.qdef] = nsdef;
oS.nsalias[nsdef] = oSchm.qdef;
}
oSchm.service = oS.url;
oSchm.elems = new Array();
oSchm.types = new Array();
oSchm.sTypes = new Array();
oS.schemas[oSchm.uri] = oSchm;
}
else
oSchm = oS.schemas[schmUri];
var nElements = nSchemas[j].childNodes;
for (var k = 0; k < nElements.length; k ++)
{
var sn = getAttrib(nElements[k], "name");
if (sn == null)
continue;
switch(nElements[k].baseName)
{
case 'element' :
oSchm.elems[sn] = parseElem(oS,oSchm,nElements[k],sn);
break;
case 'simpleType' :
case 'complexType' :
oSchm.types[sn] = parseType(oS, oSchm, nElements[k]);
break;
}
}
}
}
//
// parse Wsdl from xml DOM object
// xmlSdl[in] : xml DOM object
// szService : service url
//
function parseWsdl(oS, xmlSdl)
{
if (xmlSdl == null)
return false;
var nsq = getQualifier(xmlSdl.nodeName);
nsq = nsq.length == 0 ? "" : (nsq + ":");
var nsqMsg = nsq;
var nsqPort = nsq;
var nsqBinding = nsq;
var nsqService = nsq;
var nsqTypes = nsq;
var nMsgs = xmlSdl.selectNodes(nsq + "message");
var nPort = xmlSdl.selectNodes(nsq + "portType");
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
//
dbgPrintObject(oS.refs, "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
//
dbgPrintObject(oS.exts, "extensions");
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');
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -