trace("WS ver 0.1 is load") load ("webservices/WebServices.asc") /**************************************************** * FN:WS.as Coder:25swf CreateDate:2007-7-19 * 扩展FMS自带的WebService类,增加以下方法或功能 * 修改记录 * ****************************************************/
var WS = function(wsdlLocation, logObj, proxyURI, endpointProxyURI, serviceName, portName) { this._myws = new WebService(wsdlLocation, logObj, proxyURI, endpointProxyURI, serviceName, portName) //为myws符加parent this._myws.parent = this; //重实现WebService方法调用,更多信息可以参考WebService的实现方式 this.__resolve = function(methodName) { return function() { var args = new Array(); for (var i=0; i { args[i] = arguments[i]; } args.unshift(methodName); var callback = this._myws.stub.invokeOperation.apply(this._myws.stub, args); callback.callcount = 1; callback._myws = this._myws; callback._historyforcall = this._historyforcall; callback.ReCall = function() { callback.callcount++; var tempcallback = this._myws.stub.invokeOperation.apply(this._myws.stub, args); tempcallback.onResult = function() { callback.onResult.apply(callback,arguments) } tempcallback.onFault = function() { callback.onFault.apply(callback,arguments) } } return callback; } } } //========================================================================================================================= //覆写WebService 方法,使其指向WS,从而让WS能触法事件 //========================================================================================================================= var o = WebService.prototype; o.onLoad = function(wsdl) { //当onLoad方法被触发时,尝试把该方法传给WS(parent) this.parent.onLoad(wsdl) }
o.onFault = function(fault) { //同onLoad this.parent.onFault(fault) } //========================================================================================================================= //实现 WebService 所有的方法,并把方法指向 _myws //========================================================================================================================= var o = WS.prototype; //获取 WebService 提供的某个方法,但尝试过使用该方法,反回的是一个Object,因时间关系没有仔细研究该Object o.getCall = function(operationName) { return this._myws.getCall(operationName); } //获取 WebService 某个方法的参数列表数组(仅仅是传入参数类型),该列表数组中的元素是Object类型,里边包括参数名,参数类型等信息 //WS 在对 WebService 进行扩展时,将使用到该方法 o.getInputParameters = function(operationName) { return this._myws.getInputParameters(operationName); } //同getInputParameters,但该方法获取的是传出参数类型,关于传入传出的参数类型关系可以参考C#,java等高级语言关于这方面的知识 o.getOutputParameters = function(operationName) { return this._myws.getOutputParameters(operationName); }
o.onLoad = function(wsdl) { // this method will be called once the WSDL has been parsed and // the proxy created. It is meant to be overridden. // 该方法在WSDL被成功解析并且代理方法被成功创建时调用,这意味着你需要重写该方法 // 该方法在WS扩展后,将被WebService调用,因而假如你重构了WebService的onLoad事件,WS的onLoad事件将不会被调用 }
o.onFault = function(fault) { // this method will be called if the WSDL cannot be parsed and // the proxy cannot be created. It is meant to be overridden. // 同onFault,不同在于WSDL分析出错时会调用 }
//使用时,可直接在 callback = wsobject.wsfunction() 后使用 callback.ReCall() 或 callback.callcount 属性
|