Flex / PHP:没有services-config.xml的动态端点URL

时间:2010-11-22 07:33:12

标签: php flex

如何在运行时在与PHP通信的Flex App中更改/指定端点URL? 到目前为止,我总是使用services-config.xml。

我试图覆盖mxml远程对象中的端点,但没有成功。

我还尝试将新的通道集添加到远程对象,但后来我需要以某种方式定义目标。

非常感谢。

马丁

4 个答案:

答案 0 :(得分:1)

我正在努力解决同样的问题,这就是我斗争中出现的问题;)

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;
}

正如您所看到的,我基本上只做了您所说的尝试过的事情,我的端点在应用程序启动时部分提供在flashVars中。

答案 1 :(得分:0)

我刚刚发现这篇文章,因为我正在寻找一种不使用此service-config.xml文件的方法。 部署目的可能是一个真正的问题,我遇到了这篇文章: http://gertonscorner.wordpress.com/2008/09/06/remoteobject-using-amfphp-and-actionscript-3/

只是为了帮助那些在谷歌上搜索的人;)

答案 2 :(得分:0)

这是我可以在生成的服务存根中使用它的唯一方法:

import com.adobe.fiber.core.model_internal;

此外:

    /**
 * 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();  

答案 3 :(得分:0)

就像amfphp风格一样简单:

   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);
            }