📄 webservice.js
字号:
" message for operation '" + operationName + "'"); } } return serializer; }, //> @method webService.getSoapMessage() [A] // Return the SOAP message that will be formed from this WSRequest. // // @param wsRequest (WSRequest) web service request object // @return (String) SOAP message // @visibility xmlBinding //< getSoapMessage : function (wsRequest, flags) { wsRequest.serviceNamespace = wsRequest.serviceNamespace || this.serviceNamespace; var operationName = wsRequest.wsOperation; if (this.getOperation(operationName) == null) { this.logWarn("no such operation: '" + operationName + "' in service: " + this.serviceNamespace); return ""; } var messageSerializer = this.getMessageSerializer(wsRequest.wsOperation, flags && flags.generateResponse); // already warned about in getMessageSerializer if (messageSerializer == null) return ""; return messageSerializer.getXMLRequestBody(wsRequest, flags); }, getSampleResponse : function (operationName, data, flags, returnRequest) { return this.getSoapMessage({ wsOperation : operationName, data : data || {} }, isc.addProperties({ spoofData:true, generateResponse:!returnRequest }, flags)); }, getSampleRequest : function (operationName, data, flags) { return this.getSampleResponse(operationName, data, flags, true); }, // get the soap style, "document" or "rpc", which can be specified per operation or for the // service as a whole getSoapStyle : function (operationName) { return this.getOperation(operationName).soapStyle || this.soapStyle; }, // --------------------------------------------------------------------------------------- //> @method webService.getInputDS() // Get a DataSource representing the input message to a web service operation. // <P> // This DataSource is suitable for use as // +link{DataBoundComponent.dataSource,form.dataSource} for a form that the user fills out // when providing inputs to call this web service operation. // // @param operationName (String) name of the web service operation whose inputs the // returned DataSource will represent // @return (DataSource) DataSource representing the input message of a web service // operation // @visibility xmlBinding // @example wsdlBinding //< getInputDS : function (operationName) { return this.getMessageSerializer(operationName); }, getHeaderSchema : function (operationName, isInput) { var operation = this.getOperation(operationName), headers = isInput ? operation.inputHeaders : operation.outputHeaders; if (!headers) return null; var headerSchema = {}; for (var i = 0; i < headers.length; i++) { var partName = headers[i].part, messageSchema = this.getSchema("message:"+headers[i].message); //this.logWarn("messageSchema: " + messageSchema); var partField = messageSchema.getField(partName); //this.logWarn("partField: " + this.echo(partField)); // NOTE: simple type headers are legal, in which case we just return the field // definition headerSchema[partName] = this.getSchema(partField.type) || partField; } return headerSchema; }, //> @method webService.getInputHeaderSchema() // Get the schema for each part of the SOAP header for the input message of a given // operation, as a mapping from part name to schema. For example, given WSDL like: // <pre> // <soap:header part="SessionHeader" message="tns:HeaderMessage"/> // <soap:header part="CallOptions" message="tns:HeaderMessage/> // </pre> // The following schema would be returned: // <pre> // { SessionHeader : <i>sessionHeaderPartSchema</i>, // CallOptions : <i>callOptionsPartSchema</i> } // </pre> // The schema are instances of +link{DataSource} that can be inspected to discover the // elements and types that are legal in that header part, and can construct a valid SOAP // header part if +link{dataSource.xmlSerialize()} is invoked. // // @param operationName (String) name of an operation from this web service // @return (Object) mapping from partName to schema // @visibility xmlBinding //< getInputHeaderSchema : function (operationName) { return this.getHeaderSchema(operationName, true); }, //> @method webService.getOutputHeaderSchema() // Get the schema for each part of the SOAP header for the output message of a given // operation, as a mapping from part name to schema. For example, given WSDL like: // <pre> // <soap:header part="SessionHeader"/> // <soap:header part="CallOptions"/> // </pre> // The following schema would be returned: // <pre> // { SessionHeader : <i>sessionHeaderPartSchema</i>, // CallOptions : <i>callOptionsPartSchema</i> } // </pre> // The schema are instances of +link{DataSource} that can be inspected to discover the // elements and types that are legal in that header part, and can construct a valid SOAP // header part if +link{dataSource.xmlSerialize()} is invoked. // // @param operationName (String) name of an operation from this web service // @return (Object) mapping from partName to schema // @visibility xmlBinding //< getOutputHeaderSchema : function (operationName) { return this.getHeaderSchema(operationName, false); }, //> @method webService.getHeaderData() // Override this method to return data that should be serialized as SOAP headers for the // current operation, such as a sessionId. // <P> // Format of the returned data is the same as that documented for // +link{dsRequest.headerData}. // <P> // The object passed to this method will be a true DSRequest in the case of a DataSource // operation, or just an Object with a "data" property for web service operations // initiated by +link{webService.callOperation}. // <P> // If <code>headerData</code> is instead provided via either dsRequest.headerData or as // part of the <code>requestProperties</code> parameter to // +link{webService.callOperation,callOperation()}, this method will never be called. // // @param dsRequest (DSRequest) // @return (Object) data for SOAP headers // // @visibility xmlBinding //< getHeaderData : function (dsRequest) { }, // create an XPath selector that will select objects of the targetSchema from the output // message of the specified web service operation. // This is needed when we are interested in records of type "myObject", but which actually // have the tagName "records" in the result selectByType : function (xmlResponse, operationName, schemaName) { var operation = this.getOperation(operationName), outputMessage = this.getSchema("message:" + operation.outputMessage), targetSchema = this.getSchema(schemaName); // find the tagName the target schema will appear as in the response message var tagLocation = outputMessage.findTagOfType(targetSchema.ID), tagLocationDS = tagLocation[0], tagName = tagLocation[1], parentSchema = tagLocation[2], parentSchemaTagName = tagLocation[3], field = tagLocationDS.getField(tagName); // if we couldn't find the tagName, use the type name as a fallback (this may indicate // a response message which is not completely specified in schema, eg xsd:any) tagName = tagName || targetSchema.ID; // element definitions that were top-level in the WSDL file have a schemaNamespace // attribute and must be namespaced within the response message. Non-top-level element // definitions must not be, unless the <schema> element declares // elementFormDefault="qualified", in which case everything must be qualified. var qualify = targetSchema.mustQualify, namespace = targetSchema.schemaNamespace, xpath = "//" + (qualify ? "ns0:" : "") + tagName; /* if (parentSchema && !isc.isA.WSDLMessage(parentSchema) && targetSchema.getFieldNames().length == 1) { qualify = parentSchema.mustQualify; namespace = parentSchema.schemaNamespace; xpath = "//" + (qualify ? "ns0:" : "") + parentSchemaTagName + "/*"; this.logWarn("targetting parentSchema: " + parentSchema + " fieldName " + parentSchemaTagName + " namespace: " + namespace); } */ // handle SOAP Array encoding, which specifies essentially that there is a container // tag whose children are of a specified type, which we represent as field.multiple if (field && field.multiple) xpath = xpath + "/*"; var elements = isc.xml.selectNodes(xmlResponse, xpath, { ns0 : namespace }); if (this.logIsDebugEnabled("xmlBinding")) { this.logDebug("selecting type: '" + targetSchema + "' within message '" + operation.outputMessage + " via XPath: " + xpath + (qualify ? " using ns0: " + targetSchema.schemaNamespace : "") + " got " + elements.length + " elements", "xmlBinding"); } return elements; }, // find the schema best suited for binding a grid or editor form to the results of a // web service operation. Note this getInputDS() gives you the schema best suited for eg a // SearchForm. getDefaultOutputDS : function (operationName) { var schema = this.getResponseMessage(operationName); // skip one level of pointless containment: a complexType with just one subelement, // which is also a complexType. var fieldNames = schema.getFieldNames(); if (fieldNames.length == 1 && schema.fieldIsComplexType(fieldNames[0])) { return schema.getSchema(schema.getField(fieldNames[0]).type); } // improvements: find the first Array-like structure of elements containing simple type // fields. return schema; }, //> @method webService.getFetchDS() // Retrieve a DataSource that provides read-only access to records returned by a web // service operation. // <P> // +link{interface:DataBoundComponent,DataBound Components} can be bound to the returned // DataSource, and the +link{ListGrid.fetchData(),fetchData()} method can be invoked // to retrieve data from the web service. // <P> // The returned DataSource is only capable of the "fetch" // +link{group:dataSourceOperations,DataSource operation}, not "update", "add" or // "remove". To create a DataSource capable of full read-write access, use // +link{DataSource.operationBindings} with the // +link{OperationBinding.wsOperation,wsOperation} property set to associate each // DataSource operation with a web service operation. // // @param operationName (String) name of the web service operation to invoke to fetch // records // @param resultType (String) tag or type name of the XML element to be returned as // DataSource records // @param [operationBindingProperties] (OperationBinding Properties) // Optional additional properties for the operationType:"fetch" // +link{OperationBinding,operationBinding} which this method automatically creates. This // can be used to set properties such as +link{operationBinding.useFlatFields} or // +link{operationBinding.recordXPath} // // @group webService // @visibility xmlBinding //< getFetchDS : function (operationName, resultType, operationBindingProperties) { // if no resultType is specified, pick the first non-trivial structure if (resultType == null) resultType = this.getDefaultOutputDS(operationName); resultType = isc.isA.Object(resultType) ? resultType.ID : resultType;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -