8 Replies Latest reply on Sep 20, 2010 4:17 PM by jfb00

    Call multiple Web Services from Submit button

    Devtron Level 3

      Hello,

       

      is  it possible to call 3 different web services from one single submit button?

       

      I have tried to wire this up but it seems to only fire one web service.

       

      How can I invoke 3, in the same click event? Any ideas?

       

      Cheers

        • 1. Re: Call multiple Web Services from Submit button
          jfb00 Level 3

          Hi,

          Are you calling two different websites in your web service?

          Check make sure you are allow to do this thru your security in crossdomain file:

          http://curtismorley.com/2007/09/01/flash-flex-tutorial-how-to-create-a-crossdomainxml-file /

          If you are calling to same site address, you can call many methods or operations in the same web services as:

          http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_3.html

          Rgds

           

          Johnny

          • 2. Re: Call multiple Web Services from Submit button
            Devtron Level 3

            yes the web services are all located on the same server.

             

            the problem is, i do not want to update ALL fields every time I submit the form. There is business logic reasons why I cannot do this.

             

             

            I have seperated the form into 3 sections. I agree that the entire form should be submitted in one web service call, but my requirements will not allow me to do that.

             

            My solution is to have multiple submit buttons, for different sections of the form. Not as elegant as having ONE submit button, but this will work and is fast enough that the Asynchronous problem does not affect me.  I can see where it could though, if the web service calls take longer than a few seconds....then the user may try to update somewhere else, which would kill the previous web service call.

             

            IMO, this is a HUGE limitation in FLEX.

            • 3. Re: Call multiple Web Services from Submit button
              jfb00 Level 3

              HI,

              I use web services just to gatter info from my server, if I want to do updates and inserts I have coldfusion.

              With coldfusion I can use remote object and inside the object have many methods. One method could be for insert and just call that method in my app.

              Now when I submit a button I disable all other buttons around and display a progress bar until the transaction is complete.

              Regards

               

              Johnny

              • 4. Re: Call multiple Web Services from Submit button
                Devtron Level 3

                ^ Very interesting! Does Cold Fusion have the capability to invoke multiple web services? I do not have control over creating the web services, they are pre-defined for me to use.

                 

                For instance, I have several device objects. Each device has an ID. I may have 20 devices in my datagrid, with 20 ID's I need to update. When I update a device, it may not need to update all properties, maybe just the name of the device. I can pass in 20 device ID's to my Update Web Service, but if I need to update another property, such as device location, that is a seperate web service.

                 

                My solution is to update all data for the devices in one transaction but this is not possible, due to the architecture I must use, which is built by a different team.

                 

                So if I need to update the 20 device names, and 20 device locations, I must make two seperate web service calls.

                 

                How can I call both, with only one Submit button? The answer is, in FLEX, you cannot. You need to have two submit buttons, one for each operation. Also, you cannot click both buttons simultaneously so this introduces many problems.

                 

                Can COLD FUSION cure this? I am curious....

                • 5. Re: Call multiple Web Services from Submit button
                  jfb00 Level 3

                  Coldfusion is a server applicaition that will be in your webserver. You can create web services with coldfusion.

                  Colfusion can connect directly with your database. The way that coldfusion talk with your data in flex is using cfc's

                  CFC is a file where you declare all your methods or functions.

                  In flex you creata a connection to this cfc's with a remote object and use the functions or methods.

                  A lot to read if you want to use CF. CF is not free

                  http://www.adobe.com/devnet/flex/flex_cf.html

                  Regards

                   

                  Johnny

                  • 6. Re: Call multiple Web Services from Submit button
                    jfb00 Level 3

                    Hi,

                    I just test to call two methods using webservices and works fine.

                    From the example that i sent you:

                    <mx:WebService
                         id="userRequest"
                         wsdl="http://localhost:8500/flexapp/returnusers.cfc?wsdl">
                    
                        <mx:operation name="returnRecords" resultFormat="object"
                         fault="mx.controls.Alert.show(event.fault.faultString)"
                         result="remotingCFCHandler(event)"/>
                    
                        <mx:operation name="insertRecord" result="insertCFCHandler()"          fault="mx.controls.Alert.show(event.fault.faultString)"/> </mx:WebService> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent;     private function remotingCFCHandler(e:ResultEvent):void { dgUserRequest.dataProvider = e.result; }     private function insertCFCHandler():void { userRequest.returnRecords(); }     private function clickHandler():void { userRequest.insertRecord(username.text, emailaddress.text); } ]]>     </mx:Script>


                    When you call you methods just use:  userRequest.METHOD_NAME(parameters);
                    Regards

                    Johnny

                    • 7. Re: Call multiple Web Services from Submit button
                      Devtron Level 3

                      ^ Does this example require Cold Fusion? (I dont think it does, I just wanted to be clear).

                       

                      I suppose my problem is that i am using HTTPService Objects and not the WebService object itself.

                       

                      Maybe that will solve my problem.

                       

                      My WSDL has 500+ web services though. I assume "operation name" is the WebService method name?

                      • 8. Re: Call multiple Web Services from Submit button
                        jfb00 Level 3

                        No CF, this is using web services.

                        Correct, use web services.

                        Correct, operation is the method.

                        Good luck

                         

                        Johnny