学习remoting一段时间了,但用于实践还是头一回,总结了不少经验,特记录下来,备忘。
1.AmfPhp的配置
假设我的amfphp的路径是在根目录的 /amfphp
项目文件夹(假设为blog)中只须包含一个 gateway.php,如下:
<?php
include '/amfphp/app/Gateway.php';
$ gateway = new Gateway();
$ gateway->setBaseClassPath("services/");
$ gateway->service();
?>
就可以了
然后项目文件夹中建一Services文件夹存放我的php文件即可。
例如
blog.php
<?php
class blog{
.....
}
?>
2.flash方面:
我写了一个 db 类
传入你的路径和 serviceName即可.
例如:
var DB=new db("http://localhost/blog/gateway.php","blog");
如果blog在services中的文件夹walktree中,则为:
var DB=new db("http://localhost/blog/gateway.php","walktree.blog");
这有点类似java的namespace
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.debug.NetDebug;
import mx.services.Log;
//
class db
{
//remoting service
private var service : Service;
private var rs:RecordSet;
function db (gateURL : String,ServieceName:String)
{
NetDebug.initialize ();
//new service instance
//this.service = new Service (gateURL, new Log(Log.DEBUG, "infoLog"), ServieceName, null, null);
this.service = new Service (gateURL, null, ServieceName, null, null);
}
//..........your function
public function _getResult(){
return rs;
}
//clear result
public function clear(){
this.rs=undefined;
}
}
1.AmfPhp的配置
假设我的amfphp的路径是在根目录的 /amfphp
项目文件夹(假设为blog)中只须包含一个 gateway.php,如下:
<?php
include '/amfphp/app/Gateway.php';
$ gateway = new Gateway();
$ gateway->setBaseClassPath("services/");
$ gateway->service();
?>
就可以了
然后项目文件夹中建一Services文件夹存放我的php文件即可。
例如
blog.php
<?php
class blog{
.....
}
?>
2.flash方面:
我写了一个 db 类
传入你的路径和 serviceName即可.
例如:
var DB=new db("http://localhost/blog/gateway.php","blog");
如果blog在services中的文件夹walktree中,则为:
var DB=new db("http://localhost/blog/gateway.php","walktree.blog");
这有点类似java的namespace
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.debug.NetDebug;
import mx.services.Log;
//
class db
{
//remoting service
private var service : Service;
private var rs:RecordSet;
function db (gateURL : String,ServieceName:String)
{
NetDebug.initialize ();
//new service instance
//this.service = new Service (gateURL, new Log(Log.DEBUG, "infoLog"), ServieceName, null, null);
this.service = new Service (gateURL, null, ServieceName, null, null);
}
//..........your function
public function _getResult(){
return rs;
}
//clear result
public function clear(){
this.rs=undefined;
}
}
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}