I use a similar system in my app for disabling the controls until the service is loaded. In the "load" handler, I add handlers for faults and results for the various operations (I don't use operation tags, but instead manually register everything in AS). Here is the general idea...

    <!-- Web service connector -->
    <mx:WebService id="MyWebService" wsdl="http://services.cadtel.com/jbpm-webapp/wsdl/jbpm.wsdl"
        useProxy="false" showBusyCursor="true" concurrency="multiple"
        load="MyJbpmWebService.init(); Dashboard.enabled=true;"
        fault="MyJbpmWebService.defaultFault(event);" />


The "init()" method looks like this...

        public function init():void {
            service.addEventListener("fault", defaultFault);
            service.GetProcessDefinitions.addEventListener("result", getProcessDefinitionsResponse);
            service.GetProcessInstances.addEventListener("result", getProcessInstancesResponse);
            service.NewProcessInstance.addEventListener("result", newProcessInstanceResponse);
            service.SignalProcessInstance.addEventListener("result", signalProcessInstanceResponse);
        }


... and the method that is failing looks like this ...

        /**
         * Create XML and send &apos;getProcessInstances&apos; message to web service.
         */

        public function getProcessInstances(definitionId:int):void {
            var xml:XML = new XML(
                "<jbpm:GetProcessInstances xmlns:jbpm=\"http://org.jbpm/service\" " +
                "  xmlns:typ=\"http://org.jbpm/types\"" +
                " definitionId=\"" + definitionId + "\"/>");
            service.GetProcessInstances.request = xml;
            service.GetProcessInstances.resultFormat = "e4x";
            try {
                service.GetProcessInstances.send();
            } catch (e:WSDLError) {
                // TODO: Nasty hack to get around first call failing...
                service.GetProcessInstances.send();
            }
        }
       
        /**
         * Handles response from getProcessInstances() web service call.
         */

        protected function getProcessInstancesResponse(event:ResultEvent):void {
            if (!checkForFault(XMLList(event.result))) {
                controller.receivedGetProcessInstancesResponse(
                    XML(event.result[0].types::ProcessInstances));
            }
        }


Note the try...catch block that resubmits the message. Ths fixes the problem, but seems like a huge hack.  I have no idea why all of the other operations work fine, but the first call to that particular one always fails. It would be nice to have the source for the WebService class so that I could trace into it, but that doesn't seem to be included in the SDK.

Thanks,
Derek Adams


--- In flexcoders@yahoogroups.com, "Marco Casario" <[EMAIL PROTECTED]> wrote:
>
> I often use a "light system", that is an actionscript class who traces me the status of async processes (with RemoteObject or WebServices).
>
> If the light is red, all flex controls involved in invoking any webservice methods are disabled (I used mx:states to handle with it).
> When the light is green I make controls enabled.
>
> Hope that helps,
>
> Marco Casario
> http://casario.blogs.com
>
>
>
> ----- Original Message -----
> From: Franck de Bruijn
> To: flexcoders@yahoogroups.com
> Sent: Monday, August 07, 2006 6:33 AM
> Subject: [Norton AntiSpam] RE: [flexcoders] Re: WSDLError:Element not resolvable
>
>
>
> Hi,
>
>
>
> I am not sure if my answer is really the answer, since I personally don't use the Webservice tag, but the webservice action script classes.
>
>
>
> When a webservice is initialized, it will load the wsdl from an URL. This can take some time and is an asynchronous process. This means that the webservice loads the WSDL in the background. If it is not finished loading/parsing the wsdl and you try to invoke an operation it will return errors.
>
>
>
> Try to wait a few seconds and invoke it then, if the error still remains, then this is the reason. How to solve it? I did it like this:
>
>
>
> secWsImpl = new WebService();
>
> secWsImpl.addEventListener(LoadEvent.LOAD, handleWsLoaded);
>
> secWsImpl.addEventListener("fault", handleWsError);
>
> secWsImpl.loadWSDL("/FlexTestWebServices/wsdl/SecurityWebServiceRpcEnc8080.wsdl");
>
>
>
> In the method 'handleWsLoaded' you can then invoke an operation if you'd like, or enable a button or something like that.
>
>
>
> Cheers,
>
> Frnack
>
>
>
>
>
>
> ------------------------------------------------------------------------------
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Derek Adams
> Sent: Sunday, August 06, 2006 11:56 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: WSDLError:Element not resolvable
>
>
>
> Did you have any luck figuring this one out? I am having the same
> problem. The first call to a particular operation always fails, then
> all calls after that work fine. Even weirder is the fact that a call
> to another operation on the same service is successful right before
> the other call fails.
>
> --- In flexcoders@yahoogroups.com, "flexava" flexava@ wrote:
> >
> > I ran into a strange problem when I was trying to call a web
> > service.Here's the source:
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > layout="vertical">
> > <mx:Script>
> > <![CDATA[
> > import mx.rpc.events.FaultEvent;
> > import mx.controls.Alert;
> > import mx.rpc.events.ResultEvent;
> > import
> com.adobe.cairngorm.control.CairngormEventDispatcher;
> > import com.ceno.umc.control.LoginEvent;
> >
> > private function onResult(event :
> ResultEvent) : void
> > {
> > Alert.show(event.result.toString
> (),"result");
> > }
> >
> > private function onFault(event :
> FaultEvent) : void
> > {
> > Alert.show
> (event.fault.faultString,"faultString");
> > }
> > ]]>
> > </mx:Script>
> > <mx:WebService id="aService" service="umc/umc/auth"
> > port="umc/umc/authHttpPort"
> > wsdl="http://localhost:8008/ws/services/umc/umc/auth?
> wsdl"
> > showBusyCursor="true"
> > result="onResult(event)" fault="onFault(event)">
> > <mx:operation name="login" resultFormat="e4x">
> > <mx:request>
> > <req>
> > <subject>
> > admin
> > </subject>
> > <username>
> > admin
> > </username>
> > <password>
> > admin
> > </password>
> > </req>
> > </mx:request>
> > </mx:operation>
> > </mx:WebService>
> > <mx:Button label="Login" click="aService.login.send()"/>
> > </mx:Application>
> > when I clicked the login button it first showed me an error dialog
> saying:
> > [WSDLError faultString="Element
> http://cmd.umc.ceno.com:loginResponse
> > not resolvable" faultCode="WSDL.BadElement" faultDetail="null"]
> > at
> >
> mx.rpc.soap::WSDLParser/http://www.adobe.com/2006/flex/mx/internal::p
> arseMessage()
> > at mx.rpc.soap::WSDLOperation/parseMessages()
> > at
> >
> mx.rpc.soap::Operation/http://www.adobe.com/2006/flex/mx/internal::in
> vokePendingCall()
> > at mx.rpc.soap::Operation/send()
> > at Function/http://adobe.com/AS3/2006/builtin::apply()
> > at mx.rpc.soap.mxml::Operation/send()
> > at WSTest/___Button1_click()
> > then I clicked the login button again,eveything worked.Any idea?
> Thanks.
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to