pyamf

[color=red]pyamf和Flex交互的简单例子[/color]
Python端代码:
image_service.py
class ImageService(object):
def sayHello(self):
print "hello"


server.py
from image_service import ImageService
from pyamf.remoting.gateway.wsgi import WSGIGateway
from wsgiref import simple_server

if __name__ == '__main__':
services = { 'image_service' : ImageService}
gw = WSGIGateway(services)

httpd = simple_server.WSGIServer(
('localhost', 8000),
simple_server.WSGIRequestHandler,
)

httpd.set_app(gw)

print "Running PocketFlexDemoServer AMF gateway on http://localhost:8000"

try:
httpd.serve_forever()
except KeyboardInterrupt:
pass


Flex端代码:
只列出关键代码:
	<fx:Declarations>
<mx:RemoteObject id="remotImageService" destination="image_service" endpoint="http://localhost:8000">
<mx:method name="sayHello" result="onRemoteHelloResult(event)" fault="onDataError(event)"/>
</mx:RemoteObject>
</fx:Declarations>

private function sayHello():void
{
remotImageService.sayHello();
}
<s:Button label="Button" click="sayHello()"/>


[color=red]如何从pyamf.amf3.ByteArray取出实际的数据?[/color]
调用它的getvalue()函数。

ByteArray的结构如下图所示:
[img]http://dl.iteye.com/upload/attachment/303669/0a8c58e2-5256-3bd3-a5a6-6c808e7601f3.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值