11 Replies Latest reply on Aug 24, 2006 10:53 AM by hhr_jb

    Web Services Error

    hhr_jb
      Hello,

      Trying to do webservice and running into error message. Not sure what I'm doing wrong. I'm trying to access a database and display the content of the database into a datagrid. Can some please help.

      Here are the code
      Simple.cfc
      <cfcomponent>
      <cffunction name="returnquery" access="remote" returntype="query">
      <cfset var qBikeParts="">
      <cfquery name="qBikeParts" datasource="Error">
      SELECT * from ErrorLog
      </cfquery>
      <cfreturn qBikeParts>
      </cffunction>
      </cfcomponent>


      My MXML code
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">

      <mx:WebService id="myService"
      wsdl=" http://www.Hawaiihotels.com/WSTest/Simple.cfc?wsdl"
      load="myService.getData();"/>

      <mx:DataGrid dataProvider="{myService.getData.lastResult}"/>

      </mx:Application>

      This is the error message I get when I try to runn the application

      [RPC Fault faultString="Couldn't find method 'getData' in service." faultCode="Client.NoSuchMethod" faultDetail="null"]
      at mx.rpc.soap::Operation/mx.rpc.soap:Operation::createFaultEvent()
      at mx.rpc.soap::Operation/ http://www.adobe.com/2006/flex/mx/internal::invokePendingCall()
      at mx.rpc.soap::Operation/send()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.rpc.soap.mxml::Operation/send()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.rpc::AbstractService/ http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()
      at Database/__myService_load()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc::AbstractService/dispatchEvent()
      at mx.rpc.soap.mxml::WebService/dispatchEvent()
      at mx.rpc.soap::WebService/ http://www.adobe.com/2006/flex/mx/internal::wsdlHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc.soap::WSDLParser/dispatchEvent()
      at mx.rpc.soap::WSDLParser/::parseCompleted()
      at mx.rpc.soap::WSDLParser/ http://www.adobe.com/2006/flex/mx/internal::httpResultHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()



      Does anyone know what I'm doing wrong, or how to resolve this?

      Thanks,
      Jimmy

        • 1. Re: Web Services Error
          seth_hodgson Level 1
          Hi Jimmy,

          The error indicates that the WSDL can't be fetched and loaded by Flash. Make sure http://www.Hawaiihotels.com/WSTest/Simple.cfm?wsdl is accessible in a browser, and if your swf is not being served from that domain you will also likely need to host a cross-domain.xml file at www.Hawaiihotels.com/ to allow Flash clients access.

          Best,
          Seth
          • 2. Re: Web Services Error
            hhr_jb Level 1
            I just checked and was able to view the http://www.hawaiihotels.com/WSTest/Simple.cfc?WSDL from my browser. I am running the test from my PC, on a different subnet from the hawaiihotels.com subnet. Could that be the problem?

            Thanks,
            Jimmy
            • 3. Re: Web Services Error
              seth_hodgson Level 1
              That looks like a different error message, and in this case you're invoking getData() on the client but the CFC defines a "returnquery" function. Try updating one or the other to make the method name match?

              Best,
              Seth
              • 4. Re: Web Services Error
                hhr_jb Level 1
                Thanks for the quick reply. I'm still very new to flex. Since my cfc is returnquery, what are my option for the flex side? I'd pretty much copied and pasted sample codes from various websites tutorial. Not sure what is need to do on the flex end.

                Jimmy
                • 5. Re: Web Services Error
                  seth_hodgson Level 1
                  Try myService.returnquery() rather than myService.getData().

                  Best,
                  Seth
                  • 6. Re: Web Services Error
                    hhr_jb Level 1
                    Ok I'd changed it to returnquery(), and now I'm getting this new error message

                    Error: Cannot assign operations into an RPC Service (WSDL)
                    at mx.rpc::AbstractService/ http://www.adobe.com/2006/actionscript/flash/proxy::setProperty()
                    at Database/::_WebService1_i()
                    at Database$iinit()
                    at mx.managers::SystemManager/create()
                    at mx.managers::SystemManager/::initializeTopLevelWindow()
                    at mx.managers::SystemManager/::frameEndHandler()



                    Just wanted to make sure I have added the returnquery in the correct spot


                    <?xml version="1.0" encoding="utf-8"?>
                    <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
                    <mx:WebService id="myService"
                    WSDL=" http://www.Hawaiihotels.com/WSTest/Simple.cfc?WSDL"
                    load="myService.returnquery();"/>
                    <mx:DataGrid dataProvider="{myService.returnquery()}"/>
                    </mx:Application>
                    • 7. Re: Web Services Error
                      seth_hodgson Level 1
                      Sorry, the load attribute in the WebService tag expects an event handler. So you'd need something along the lines of:

                      <mx:WebService ... load="handleLoad(event)" .../>

                      In a script block, define your handler:

                      private function handleLoad(event:Event):void
                      {
                      myService.returnquery();
                      }

                      I haven't tried binding CFQueries to anything but you'll be able to access the result of your call several possible ways:
                      1. myService.returnquery.lastResult
                      2. Register a result event handler for your WebService instance - when you make calls you get back an AsyncToken that you can add state to. This same token is available to you in your result handler so you can link the async result up with the original call.
                      3. You can add a responder to the token you get back from your call. When a result or fault is returned from the server it will be passed to the result() or fault() event on your responder.

                      Best,
                      Seth
                      • 8. Re: Web Services Error
                        hhr_jb Level 1
                        Hey Seth,

                        Really appreciate all of your help. So I did what you were sugessting and now getting a differnt error messgae. But first of all is my flex code even correct?

                        Flex Code
                        <?xml version="1.0" encoding="utf-8"?>
                        <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
                        <mx:Script>
                        <![CDATA[
                        import mx.collections.ArrayCollection;
                        import mx.rpc.events.ResultEvent;
                        [Bindable]
                        private var myData:ArrayCollection;
                        private function resultHandler(event:ResultEvent):void{
                        myData=event.result as ArrayCollection;
                        }
                        ]]>
                        </mx:Script>
                        <mx:WebService id="myService"
                        WSDL=" http://www.Hawaiihotels.com/WSTest/Simple.cfc?wsdl"
                        load="myService.getquery();"
                        result="resultHandler(event)"/>
                        <mx:DataGrid dataProvider="{myData}"/>
                        </mx:Application>


                        Error Message
                        Error: Cannot assign operations into an RPC Service (WSDL)
                        at mx.rpc::AbstractService/ http://www.adobe.com/2006/actionscript/flash/proxy::setProperty()
                        at Database/::_WebService1_i()
                        at Database$iinit()
                        at mx.managers::SystemManager/create()
                        at mx.managers::SystemManager/::initializeTopLevelWindow()
                        at mx.managers::SystemManager/::frameEndHandler()

                        Thanks

                        Jimmy

                        • 9. Re: Web Services Error
                          seth_hodgson Level 1
                          Hi Jimmy,

                          Take a look at my previous posting. I think you still need to make that change to the load attribute of your tag. The load, result and fault attributes of the tag expect a handler function. So something like:

                          <mx:WebService ... load="handleLoad(event)" .../>

                          rather than

                          <mx:WebService ... load="load="myService.getquery();" ... />

                          Best,
                          Seth
                          • 10. Re: Web Services Error
                            hhr_jb Level 1
                            Hey Seth,

                            I've rewrote my cfc and flex code now based on what you had suggested. Now I have everything compiled and executing, put I do not get anything populated in my datagrid. Do you know what could be the problem.

                            Here's the new CFC code
                            <cfcomponent>
                            <cffunction name="getData" access="remote" returntype="query">
                            <cfquery name="ELogs" datasource="Error">
                            SELECT * from ErrorLog
                            </cfquery>

                            <cfreturn ELogs>
                            </cffunction>
                            </cfcomponent>


                            Here's the New Flex code.
                            <?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.ResultEvent;
                            import mx.collections.ArrayCollection;

                            [Bindable]
                            private var myData:ArrayCollection;

                            private function resultHandler(event:ResultEvent):void{
                            myData = event.result as ArrayCollection
                            }
                            ]]>
                            </mx:Script>
                            <mx:WebService id="myService"
                            wsdl=" http://www.hawaiihotels.com/WSTest/Simple1.cfc?wsdl"
                            load="myService.getData();"
                            result="resultHandler(event)"/>

                            <mx:DataGrid dataProvider="{myData}"/>
                            </mx:Application>


                            Thanks,
                            Jimmy
                            • 11. Re: Web Services Error
                              hhr_jb Level 1
                              I got the code to work now.

                              What I did was change the dataprovider to myService.getData.lastResult, and bam all the data came in.

                              Thanks for everything.

                              Jimmy