0
votes

how would I change/specify the endpoint URL at runtime in a Flex App which communicates with PHP? I always used a services-config.xml so far.

I tried to overwrite the endpoint in the mxml Remote Object, with no success.

I also tried to add a new channel set to the Remote Object, but then I needed to define a destination somehow.

Help much appreciated.

Martin

4

4 Answers

1
votes

I was struggling with the same issue and here's what emerged from my struggle ;)

public static function getRemoteObject(destination:String, channelName:String,
    showBusyCursor:Boolean=true):RemoteObject{
    var remoteService:RemoteObject=new RemoteObject(destination);
    var channelSet:ChannelSet=new ChannelSet();
    var amf:AMFChannel=new AMFChannel(channelName,
        "http://{server.name}:{server.port}" +
        (Application.application as Application).parameters.contextRoot +
        "/graniteamf/amf");
    channelSet.addChannel(amf);
    remoteService.channelSet=channelSet;
    remoteService.showBusyCursor=showBusyCursor;
    return remoteService;
}

So as you can see, I basically do just the things you said you've tried, with my endpoint being partially provided in flashVars at application startup.

0
votes

I just came across this post because i'm looking for a way that does not use this services-config.xml file. Wich for deployement purpose can be a real problem and I came across this post : http://gertonscorner.wordpress.com/2008/09/06/remoteobject-using-amfphp-and-actionscript-3/

Just to help those who googled their way here ;)

0
votes

This is the only way I could get it to work, in the generated stub for your service:

import com.adobe.fiber.core.model_internal;

Also:

    /**
 * Override super.init() to provide any initialization customization if needed.
 */
protected override function preInitializeService():void
{           
    _needWSDLLoad = false; // to prevent loading the default WSDL
    super.preInitializeService();
    // Initialization customization goes here
    wsdl = "http://localhost/yourservice?wsdl";
    _needWSDLLoad = true;
    model_internal::loadWSDLIfNecessary();  
0
votes

as simple as amfphp style :

   gateway = new NetConnection();
   gateway.connect("http://localhost/ZServer/");
   gateway.call("MyService.getData", new Responder(getLoan, onFault));

   public function getLoan(result:Array):void {
                dpDataRaw = new ArrayCollection(result);
            }