首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在中使用AMFPHP

如何在中使用AMFPHP
EN

Stack Overflow用户
提问于 2019-10-04 17:55:16
回答 2查看 346关注 0票数 3

关于使用SimpleRemoteObject,我有一个问题。(sdk 0.9.6)

我的实际网站使用这段代码使用Amfphp调用远程函数:

代码语言:javascript
复制
<mx:RemoteObject id="ro" source="aadmin" destination="amfphp">
    <mx:method name="siteLogin" fault="{onRcv_siteLoginErr(event)}" result="{onRcv_siteLogin(event)}"/>
</mx:RemoteObject>

由于Apache中不存在<mx:method/>,所以我设置了以下代码:

代码语言:javascript
复制
 </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类服务名称。

为了调用我的职能,我做了:

代码语言:javascript
复制
 sro.send("siteLogin",["123"]);

其中siteLogin是我在aadmin类中调用的函数

运行这个,我有一个问题:

代码语言:javascript
复制
The class {Amf3Broker} could not be found under the class path {/home/www/amfphp/services/amfphp/Amf3Broker.php}

为什么它会显示Amf3Broker?有谁有使用SimpleRemoteObjectamfphp一起工作的例子吗?

服务器端我使用https://github.com/silexlabs/amfphp-1.9

我需要设置一个service-config.xml文件吗?如果是,如何与编译器一起使用?(我在compilerOptions中尝试了"services":“servics-config.xml”,但不起作用)

下面是我的service-config.xml:

代码语言:javascript
复制
<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做了一个测试

这是好一点,但我有一个错误。_explicitType属性似乎存在问题。此外,我在requestMessage中没有看到我的论点('123')

代码语言:javascript
复制
    /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   

谢谢你的帮忙..。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-10-07 10:19:34

下面是在0.9.6SDK上测试的一些工作代码(请注意,如果有mx库问题,您必须使用config flex才能使用mx )。用来自silexlab的v1.9和v2.0AMFPHP进行了测试:

代码语言:javascript
复制
<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>

然后在剧本里

代码语言:javascript
复制
ro.getOperation("your-php-function-to-call").send("your-param");

更新重要:确保在您的应用程序中包含此内容,否则会出现类似于*The class {Amf3Broker} could not be found*的错误

代码语言:javascript
复制
<mx:beads>
    <js:ClassAliasBead />
</mx:beads>

update#2你用config royale做什么,还想让MX库使用MX远程对象吗?以下是如何做到的:https://github.com/apache/royale-asjs/issues/495#issuecomment-539906300

票数 2
EN

Stack Overflow用户

发布于 2019-10-04 19:00:36

我知道的后端(根据我自己的经验)是、Java、和。AMFPHP也必须工作。其他人也尝试过,但大约一年前,AMF还没有完全开发出来。目前,Royale中的AMF非常健壮,除向量和字典外,所有类型都运行得很好(我想有一天会出现这些类型,但由于是AS3类型,目前优先级较低)。

这里的主要内容是使用MXRoyale版本的RemoteObject (mx:RemoteObject仿真),因为这个版本最接近Flex RemoteObject。Network库中的其他类是作为珠子实现的更轻的类,这些珠子是最早来到Royale的。但至少在我的情况下,我切换到了mx:RemoteObject,这样我就可以确保其他人在同一级别上工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58241175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档