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

📄 webservice.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 4 页
字号:
/*
 * Isomorphic SmartClient
 * Version 6.5 (2008-04-30)
 * Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
 * "SmartClient" is a trademark of Isomorphic Software, Inc.
 *
 * licensing@smartclient.com
 *
 * http://smartclient.com/license
 */
//> @class WebService// Class representing a WebService definition derived from a WSDL file.// <P>// A Web Service object allows you to invoke operations (via// +link{method:WebService.callOperation(),callOperation()}), inspect schema declared in the// WSDL file (+link{method:WebService.getSchema(),getSchema()}), and perform simple read-only// databinding +link{method:WebService.getFetchDS()}.  // <P>// Once a WebService has been loaded, a DataSource can be declared with a// +link{attr:DataSource.serviceNamespace} to connect it to the web service, allowing DataSource// data to be loaded and saved to the web service using// +link{class:OperationBinding,operationBindings}.//// @group webService// @treeLocation Client Reference/Data Binding// @visibility xmlBinding//<isc.defineClass("Schema", "DataSource").addProperties({    dataFormat : "xml",    // NOTE: currently all subclasses of Schema are generated from various XML formats.  We    // assume they shouldn't be global variables, which is really just intended as a    // convenience for user-authored DataSources.    addGlobalId:false});isc.defineClass("WSDLMessage", "Schema").addMethods({        getWSOperation : function () {        var service = this.getWebService();        // HACK: find the operation whose input message matches our ID with the prefix        // "message:" removed        var operation = service.operations.find("inputMessage", this.ID.substring(8));        if (operation) return operation;        return service.operations.find("outputMessage", this.ID.substring(8));    }});isc.defineClass("XSElement", "Schema");isc.defineClass("XSComplexType", "Schema");//> @class SchemaSet// A set of schema derived from the &lt;xsd:schema&gt; element in a WSDL or XML schema file// loaded by +link{XMLTools.loadWSDL()} or +link{XMLTools.loadXMLSchema()}.//// @treeLocation Client Reference/Data Binding// @visibility xmlBinding//<isc.defineClass("SchemaSet").addMethods({    //> @attr schemaSet.schemaNamespace (URI : null : R)    // Namespace of this SchemaSet, derived from the <code>targetNamespace</code>    // attribute of the <code>&lt;schema&gt;</code> element.    //    // @group webService    // @visibility xmlBinding    //<    init : function () {        // register the schemaSet globally with the SchemaSet class        var schemaNamespace = this.schemaNamespace,            registry = isc.SchemaSet.schemaSets,            existingSchema = registry[schemaNamespace];        // an xs:schema that contains only an xs:import generates an empty SchemaSet.  Don't        // clobber an existing, non-empty schemaset with an empty version of the schemaset        // loaded later        if (existingSchema == null ||             // empty existing schemaset            ((existingSchema.schema == null && existingSchema.schema.length == 0) &&            // non-empty new schemaset            (this.schema != null && this.schema.length != 0)))        {            registry[schemaNamespace] = this;        }        var serviceNamespace = this.serviceNamespace;        if (this.schema) {            this._typeIndex = {};            this._elementIndex = {};            for (var i = 0; i < this.schema.length; i++) {                var schema = this.schema[i];                // ensure all schema that belong to this set have their schemaNamespace                // attribute set                schema.serviceNamespace = serviceNamespace;                schema.schemaNamespace = schemaNamespace;                // make an index of all the schema in this SchemaSet                if (schema.ID) {                                        if (isc.isAn.XSElement(schema)) {                        this._elementIndex[schema.ID] = schema;                    } else {                        this._typeIndex[schema.ID] = schema;                    }                }            }        }        // for loadXMLSchema() callback to return loaded SchemaSet        isc.SchemaSet._lastLoaded = this;     },    //> @method schemaSet.getSchema() [A]    // Get the schema definition of any complexType or element of complexType defined within    // the &lt;schema&gt; element this SchemaSet represents.    //    // @param schemaName (String) name of the schema to retrieve    // @param [schemaType] (String) optional type of schema to return, either "element" for    //                              xs:element definitions only or "type" for xs:complexType    //                              definitions.  If unspecified, either will be returned,    //                              with types preferred if names collide    // @return (DataSource) the schema if found, or null    // @visibility xmlBinding    // @example xmlSchemaImport    //<    getSchema : function (schemaName, schemaType) {        if (schemaType == isc.DS._$element) return this._elementIndex[schemaName];        if (schemaType == isc.DS._$type) return this._typeIndex[schemaName];        return this._typeIndex[schemaName] || this._elementIndex[schemaName];    }});isc.SchemaSet.addClassMethods({    schemaSets : {},    //> @classMethod SchemaSet.get() [A]    // Retrieve a SchemaSet object by it's schemaNamespace.    //    // @param schemaNamespace (String) uri from the "targetNamespace" attribute of the    // &lt;xsd:schema&gt; element from the XML Schema or WSDL file this SchemaSet was derived    // from.    // @return (SchemaSet) the requested SchemaSet, or null if not loaded    //     // @visibility xmlBinding    //<    get : function (schemaNamespace) {        return this.schemaSets[schemaNamespace];    }});//> @class WSRequest// A WSRequest (or "web service request") is an extended RPCRequest will additional properties// application to WSDL/SOAP web services.// <P>// All properties which are legal on +link{class:RPCRequest} are legal on a WSRequest, in// addition to the properties listed here.//// @treeLocation Client Reference/Data Binding// @see RPCRequest// @visibility external//<//> @attr wsRequest.wsOperation (String : null : IR)// Name of the web service operation to invoke.//// @visibility external//<//> @attr wsRequest.data (any : null : IR)// Data to be serialized to XML to form the SOAP body.//// @visibility external//<//> @attr wsRequest.useFlatFields (boolean : null : IR)// @include dsRequest.useFlatFields// @visibility external//<//> @attr wsRequest.headerData (any : null : IR)// Data to be serialized to form the SOAP headers, as a map from the header part name to the// data.  For example, given WSDL like this:// <pre>//     &lt;soap:header part="SessionHeader" message="tns:HeaderMessage"/&gt;//     &lt;soap:header part="CallOptions" message="tns:HeaderMessage/&gt;// </pre>// <code>headerData</code> like this might be provided:// <pre>//     dsRequest.headerData = //         { SessionHeader : <i>data</i>//           CallOptions : <i>data</i> };// </pre>// The provided data will be serialized to XML by the// +link{webService.getInputHeaderSchema,SOAP header schema} via// +link{dataSource.xmlSerialize()} //// @visibility external//<isc.defineClass("WebService").addMethods({    //> @attr webService.serviceNamespace (URI : null : R)    // Namespace of this WebService, derived from the <code>targetNamespace</code>    // attribute of the <code>&lt;wsdl:definitions&gt;</code> element.    //    // @group webService    // @visibility xmlBinding    //<    init : function () {        // mark all messages with the service namespace        var namespace = this.serviceNamespace;        if (this.messages) {            for (var i = 0; i < this.messages.length; i++) {                this.messages[i].serviceNamespace = namespace;            }        }        // register globally        this.logInfo("registered service with serviceNamespace: " + namespace);        isc.WebService.services[namespace] = this;        // for loadWSDL() callback to return WebService        isc.WebService._lastLoaded = this;     },    getOperation : function (operationName) {        if (isc.isAn.Object(operationName)) return operationName;        return this.operations.find("name", operationName);    },    //> @method webService.getOperationNames()    // @return (Array) names of the available operations supported by this service (array of strings)    // @group webService    // @visibility xmlBinding    //<    getOperationNames : function () {        return this.operations.getProperty("name");    },    //> @method webService.getSchema()    // Get the schema definition of any complexType or element of complexType defined in any    // &lt;schema&gt; blocks in the WSDL file this WebService represents.    //     // @param schemaName (String) name of type or element    // @param [schemaType] (String) optional type of schema to return, either "element" for    //                              xs:element definitions only or "type" for xs:complexType    //                              definitions.  If unspecified, either will be returned,    //                              with types preferred if names collide    // @return (DataSource) requested schema    // @group webService    // @visibility xmlBinding    //<    getSchema : function (name, schemaType) {        // look up all the schemaSets that the WSDL file referred to.        // do this lazily so order of creation doesn't matter for SchemaSets and WebServices        // loaded from one WSDL file        var schemaSets = this._schemaSets;        if (!schemaSets) {            schemaSets = this._schemaSets = [];            var imports = this.schemaImport;            if (imports) {                if (!isc.isAn.Array(imports)) imports = [imports];                var namespaces = imports.getProperty("namespace");                for (var i = 0; i < namespaces.length; i++) {                    var schemaNamespace = namespaces[i],                        schemaSet = isc.SchemaSet.get(schemaNamespace);                    if (schemaSet == null) {                        this.logWarn("Could not find SchemaSet for schemaNamespace: '" +                                     schemaNamespace + "', schema imported via 'xs:import' must " +                                     "be separately loaded via loadXMLSchema");                    }                    schemaSets.add(schemaSet);                }            }

⌨️ 快捷键说明

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