2 Replies Latest reply on May 29, 2006 11:29 PM by poonamsheth

    Remote Object

    tbranden
      Hello everybody

      My querstion: Is there a possibility to change the endpoint argument in a remote object, dynamicly?

      Thanks for your answers.

      greez thomas
        • 1. Re: Remote Object
          poonamsheth Level 1
          yes i think we can..

          i have read about it,

          RemoteObject calls to an endpoint are batched (with workaround)
          When multiple calls are made to an AMF gateway (via RemoteObject) in rapid succession (under the covers - when the calls get made in the same frame) the calls are part of the same AMF request and thus the responses come back as part of the same response. This means that if I called 5 methods, and one of them took 5 seconds and the rest just milliseconds, they would all come back after 5 seconds. In many cases, this is not terribly important and is intended to optimize/minimize requests and responses. However, in the event that this is problematic for an application, the workaround is as follows:

          Create individual RemoteObject tags for each method/call that need to be returned asynchronously. Since connection pooling is based on the endpoint attribute, you would need to append some sort of arbitrary string to the endpoint address so that they are unique as far as the connection pooling mechanism is concerned.

          Here's an example:
          its a example of flex 1.5.(some changes need to be done for flex2b3)

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml" xmlns="*"
          initialize="initApp()">

          <mx:Script>

          function initApp() {

          s1.slowMethod(5000);
          s2.slowMethod(2000);
          s3.slowMethod(100);

          }

          function resultHandler(event) {
          log.text+=event.result+"\n";
          }

          </mx:Script>

          <mx:RemoteObject id="s1" source="samples.explorer.SlowServiceSimulator" endpoint="/flex15/amfgateway?a" result="resultHandler(event)"/>
          <mx:RemoteObject id="s2" source="samples.explorer.SlowServiceSimulator" endpoint="/flex15/amfgateway?b" result="resultHandler(event)"/>
          <mx:RemoteObject id="s3" source="samples.explorer.SlowServiceSimulator" endpoint="/flex15/amfgateway?c" result="resultHandler(event)"/>

          <mx:TextArea id="log" width="100%" height="100%"/>

          </mx:Application>
          -------------------
          Remember that this workaround would only need to be applied in circumstances where you make multiple calls to the same endpoint at the same time and need to ensure that calls are returned asynchronously (specifically, if some calls may take substantially longer than others and it's important that the faster calls are returned ASAP).
          • 2. Re: Remote Object
            poonamsheth Level 1
            For HTTP service its also possible.

            HTTP service properties

            You use the url and dynamic-url properties to configure Proxy Service destinations for HTTP services in the Flex services configuration file. The following table describes those properties:

            Parameter
            ----------------
            Description
            url

            Optional default URL.
            dynamic-url

            Optional HTTP service URL patterns. You can use more than one dynamic-url entry to specify multiple URL patterns. Flex matches these values against url property values that you specify in client-side service tags or ActionScript code.

            The following example shows a destination configuration for an HTTP service:

            ...
            <destination id="samplesProxy">
            <channels>
            <channel ref="samples-amf"/>
            </channels>

            <properties>
            <dynamic-url>{context.root}/photoviewer/*</dynamic-url>
            <dynamic-url>{context.root}/blogreader/*</dynamic-url>
            <dynamic-url>{context.root}/services/*</dynamic-url>
            </properties>
            </destination>
            ...