Construct your Webservice API (Flashmx2004 Professional)

zhaozj2021-02-16  73

class pack.services.MyWebService {/ * * webservice object * / private var webService: mx.services.WebService; / * * record service's address * / private var WSDL: String; / * * service's call back object * / public var callBack : Object; / ** * constructure * @param address: webservice's address * / function MyWebService (address: String) {WSDL = address; this.webService = new mx.services.WebService (address); this.webService.WSDL = address ; this.webService.onFault = onLoadFault;} / ** * call service's method * @param methodName: the method which called * @param object: paramaters the method required * @param resultFunction: function which to do after the called success * @ param statusFunction: function which to do when call the method fail * / function accessRemote (methodName: String, object: Object, resultFunction: function, statusFunction: function) {this.callBack = this.webService [methodName] (object ); This.callBack.onResult = resultFunction; this.callBack.onFault = statusFunction;} / ** * when load service fail, do this function * / function onLoadFault (fault) {trace ( "load service" WSDL "error ---> " fault.faultcode);}}

Instructions:

Var myservice = new pack.services.mywebservice ("http: // localhost: 8080 / axis / services / smsservice? WSDL"); var message = new pack.model.Mestage (); message.setContents ("I am a Wolves from the North "); Message.SetFrom (" Harbin "); Message.SetPriority (123456); Message.Setto (" Shanghai "); MyService.accessRemote (" Send ", Message, OnResult, Onfault;

Function OnResult ("Call Service OK ---->" Result.code);} Function Onfault ("Call Service Fault --->" Fault.FaultCode);}

转载请注明原文地址:https://www.9cbs.com/read-16376.html

New Post(0)