我在使用SimpleRemoteObject
时遇到问题。(SDK 0.9.6(
我的实际网站使用此代码使用 Amfphp 调用远程函数:
<mx:RemoteObject id="ro" source="aadmin" destination="amfphp">
<mx:method name="siteLogin" fault="{onRcv_siteLoginErr(event)}" result="{onRcv_siteLogin(event)}"/>
</mx:RemoteObject>
由于<mx:method/>
在Apache Royale中不存在,因此我设置了以下代码:
</js:beads>
<js:SimpleRemoteObject id="sro" source="aadmin" result="onResult(event)" fault="onFault(event)"
endPoint = "http://amfphp.myserver_url.com/gateway.php"
destination = "amfphp" />
</js:beads>
aadmin
是我的 PHP 类服务名称
要调用我的函数,我这样做:
sro.send("siteLogin",["123"]);
其中siteLogin
是我在类中调用aadmin
函数
运行这个,我有这个问题:
The class {Amf3Broker} could not be found under the class path {/home/www/amfphp/services/amfphp/Amf3Broker.php}
为什么显示Amf3Broker
?有没有人有与amfphp
一起工作SimpleRemoteObject
的例子?
我使用 https://github.com/silexlabs/amfphp-1.9 服务器端
我需要设置service-config.xml
文件吗?如果是,如何与编译器一起使用?(我在编译器选项中尝试了"服务":"服务配置.xml",但不起作用(
这是我的服务配置.xml :
<services-config>
<services>
<service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
<destination id="amfphp">
<channels>
<channel ref="my-amfphp"/>
</channels>
<properties>
<source>*</source>
</properties>
</destination>
</service>
</services>
<channels>
<channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://amfphp.myserver.com/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties><add-no-cache-headers>false</add-no-cache-headers></properties>
</channel-definition>
</channels>
</services-config>
现在我用amfphp V2.0
做了一个测试 https://github.com/silexlabs/amfphp-2.0
这好一点,但我有一个错误。看来_explicitType
财产有问题。此外,我在 [请求消息] 中没有看到我的论点('123'(
/onStatusî$flex.messaging.messages.ErrorMessage
correlationId faultCode@ faultDetailfaultStringvUndefined property: stdClass::$_explicitType .
<br>file: /home/www/mysite.com/amfphpv2/Plugins/AmfphpFlexMessaging/AmfphpFlexMessaging.php
<br>line: 113
<br>context: Array
(
[requestMessage] => Amfphp_Core_Amf_Message Object
(
[targetUri] => null
[responseUri] => /1
[data] => Array
(
[0] => stdClass Object
(
[body] => stdClass Object
(
)
[clientId] =>
[correlationId] =>
[destination] => amfphp
[headers] => stdClass Object
(
)
[messageId] => EF4BF9E3-5C02-1060-1FF3-5D9781F55A31
[operation] => 13
[timeToLive] => 0
[timestamp] => 0
)
)
)
[serviceRouter] => Amfphp_Core_Common_ServiceRouter Object
(
[serviceFolders] => Array
(
[0] => /home/www/mysite.com/amfphpv2/Core/../Services/
)
[serviceNames2ClassFindInfo] => Array
(
[AmfphpMonitorService] => Amfphp_Core_Common_ClassFindInfo Object
(
[absolutePath] => /home/www/mysite.com/amfphpv2/Plugins/AmfphpMonitor/AmfphpMonitorService.php
[className] => AmfphpMonitorService
)
[AmfphpDiscoveryService] => Amfphp_Core_Common_ClassFindInfo Object
(
[absolutePath] => /home/www/mysite.com/amfphpv2/Plugins/AmfphpDiscovery/AmfphpDiscoveryService.php
[className] => AmfphpDiscoveryService
)
)
[checkArgumentCount] => 1
)
[explicitTypeField] => _explicitType
)
rootCause
提前感谢您的任何帮助...
以下是在 0.9.6 sdk 上经过测试的一些工作代码(请注意,如果您有 mx 库问题,您必须使用config flex
才能使用 mx(。 使用 silexlabs 的 v1.9 和 v2.0 AMFPHP 进行测试:
<fx:Declarations>
<mx:RemoteObject id="ro" result="onResult(event)" fault="onFault(event)" source="your-service-php-class"
endpoint = "https://www.your-amfphp-server.com/amfphp/gateway.php"
destination = "amfphp" />
</fx:Declarations>
然后在脚本中
ro.getOperation("your-php-function-to-call").send("your-param");
[更新]重要提示:请务必在您的应用程序中包含此功能,否则将出现类似*The class {Amf3Broker} could not be found*
<mx:beads>
<js:ClassAliasBead />
</mx:beads>
[更新#2] 你用什么config royale
但也想让 MX 库使用 MX 远程对象?方法如下: https://github.com/apache/royale-asjs/issues/495#issuecomment-539906300
我知道的后端(根据我自己的经验(是Java和.NET(Fluorine(。AMFPHP也必须发挥作用。其他人尝试过,但差不多一年前,当AMF还没有完全开发出来时。现在,Royale中的AMF非常强大,并且适用于所有类型,除了矢量和字典(我想这些总有一天会到来,但由于是AS3类型,目前优先级较低(。
这里最主要的是使用MXRoyale
版本的RemoteObject
(mx:RemoteObject
仿真(,因为这个版本最接近Flex RemoteObject。Network
lib 中的其他是更轻的类,作为珠子实现,是第一批来到皇家的。但至少在我的情况下,我切换到mx:RemoteObject
,所以我可以确保其他人在同一水平上工作。