Hello,
I've written a small flex client to test my amfrpc service. It works
fine in web2py, but not in gae.
The gae log shows
INFO 2009-04-21 03:24:55,043 dev_appserver.py] "POST /cuecut/
projects/call/amfrpc HTTP/1.1" 200 -
which seems normal, but my function is not firing. Could someone
verify? After running the flex app and Create Project form will
display with 5 fields. Just click submit to verify that it contacts
the service and calls function f(a,b,c). It should just concatenate
the hardcoded values and return <project_id>onetwothree</project_id>
Thanks!
-Dave
My controller function:
@service.amfrpc
# usage: projects/call/xml/f/a/b/c
def f(a,b,c):
print a, b, c
return a+b+c
My mxml code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="middle"
backgroundColor="#FFFFFF" backgroundAlpha="0">
<mx:Form label="Login">
<mx:FormItem label="Create Project"/>
<mx:FormItem label="name:">
<mx:TextInput id="name_txt"/>
</mx:FormItem>
<mx:FormItem label="description:">
<mx:TextInput id="description_txt"/>
</mx:FormItem>
<mx:FormItem label="summary:">
<mx:TextInput id="summary_txt"/>
</mx:FormItem>
<mx:FormItem label="type:">
<mx:TextInput id="type_txt"/>
</mx:FormItem>
<mx:FormItem label="owner_id:">
<mx:TextInput id="owner_id_txt"/>
</mx:FormItem>
<mx:FormItem horizontalAlign="right" paddingBottom="10">
<mx:Button label="Submit" click="submit(event)"/>
</mx:FormItem>
<mx:Text id="status_txt" textAlign="center" fontWeight="bold"
width="250" height="100"/>
</mx:Form>
<mx:Script>
<![CDATA[
import flash.net.NetConnection;
import flash.net.Responder;
// Gateway connection object
private var gateway:NetConnection;
// submit action
public function submit( event:MouseEvent ): void
{
var name:String = name_txt.text;
var description:String = description_txt.text;
var summary:String = summary_txt.text;
var type:String = type_txt.text;
var owner_id:String = owner_id_txt.text;
// Setup connection
gateway = new NetConnection();
// Connect to gateway
gateway.connect( "http://localhost:8000/app/controller/
call/amfrpc");
// Set responder property to the object and methods that
will receive the
// result or fault condition that the service returns.
var responder:Responder = new Responder( onResult,
onFault );
// Call remote service.method: call(function. responder,
param1, param2)
gateway.call( "f", responder, 'one', 'two', 'three' );
}
// Result handler method
private function onResult( result:* ): void
{
var myData:String = result;
trace( myData );
status_txt.text = "Success: data = " + myData;
}
// Fault handler method displays error message
private function onFault( error:* ): void
{
// Notify the user of the problem
status_txt.text = "Remoting error:";
for ( var d:String in error ) {
status_txt.text += error[d] + "\n";
}
}
]]>
</mx:Script>
</mx:Application>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---