PDA

View Full Version : amfphp Problems calling more than one method on one service


clem_c_rock
04-28-2004, 03:21 PM
Hello

I am having a great time implementing amfphp in a work project - until now that is.
everything is going well until I try to call 2 functions on the same service as in the code below.


import org.amfphp.remoting.NetServices;
NetServices.setDefaultGatewayUrl("gateway.php");
var conn = NetServices.createGatewayConnection();

service = conn.getService("products",this);

//==== class function calls =================
service.get_conversation_data();
service.get_segments();
//====================================

now if I use one or the other they will work independently but not together.

IE:

service.get_conversation_data(); // -->> Works!!!!
//service.get_segments();

service.get_conversation_data(); // -->> DOES NOT WORK!!!!!!!
service.get_segments();


ANY IDEAS?

Thanks for any help anyone can give.

CLEM C

prt1
04-29-2004, 01:57 AM
When you say they don't work what gets returned in the NetDebugger.
I have a site that loads in more than 4 calls at once OK.
One way around your problem is to put the second call in the Results function of the first call.

clem_c_rock
04-29-2004, 10:15 AM
I really appreciate the help. I just don't get it. Every example I find it shows at least 2 functions being called at once.

Do you have a snippit of code where you called these 4 functions?

I'm only 1 week into amfphp and I'm exactly sure what you mean by the Netdebugger?

I like the suggestion of calling the second func in the results of the first.

Was pondering that last night. I would still like to find what is not working w/ my first approach.

Thanks again,
Clem C

CyanBlue
04-29-2004, 10:26 AM
Howdy and Welcome... :)

Why not post what you have??? Maybe that might be easier to solve the problem??? ;)

prt1
04-29-2004, 11:06 AM
The NetDebugger window shows the status of your NetService requests, ie what was passed and returned and if errored.
Depending on your version of Flash it is available from one of the menus at the top, I think one of them is the Windows menu.

clem_c_rock
04-29-2004, 11:34 AM
Ok Further testing on this class showed the same thing. I pulled this off a tutorial where 2 methods were called at the same time. I tested it and both functions would not work together. Here's the code:

//==== PHP CLASS: ==============================
class EchoTest
{
function EchoTest( )
{
$this->methodTable = array
(
"echoString" => array
(
"description" => "return uCase words",
"access" => "remote",
"arguments" => array( array( "name" => "string", "required" => true, "type" => "string" ))
),
"echoDate" => array
(
"description" => "returns Date",
"access" => "remote",
"arguments" => array( "data" ),
"returns" => "date"
)

);
}

function echoString( $data ){ return ucwords( $data ); }
function echoDate( $data ){ return $data; }
}

AND HERE'S THE ACTIONSCRIPT:

#include "NetServices.as"
#include "NetDebug.as"

mainResponder = new Object();

mainResponder.echoString_Result = function( data )
{
txt_output += "\n echoString result";
txt_output += "\n recieved: " + data + "\n-------------";
}

mainResponder.echoDate_Result = function( data )
{
txt_output += "\n echoDate result";
txt_output += "\n recieved: " + data + "\n-------------";
}

mainResponder.onStatus = function ( data )
{
txt_output += "\n ERROR: " + data + "\n line: " + data.line + " \n description: " + data.description;
}

NetServices.setDefaultGatewayUrl("gateway.php");
conn = NetServices.createGatewayConnection();
serv = conn.getService("EchoTest", mainResponder);

serv.echoString("this is a test");
serv.echoDate(new Date() );
//=========================================

Now the calls and errors:

//serv.echoString("this is a test");
serv.echoDate(new Date() ); //-->> This works!!!!!

serv.echoString("this is a test"); //-->> This works!!!!!
//serv.echoDate(new Date() );

serv.echoString("this is a test"); //-->> THIS DOESN'T WORK !!!!!
serv.echoDate(new Date() ); //-->> THIS DOESN'T WORK !!!!!

One clue I get is from the output description. Here's the message:

"description: no class named EchoTest is known to the gateway"

Now this is making me believe there is something wrong w/ my version of amfphp

Thanx for any help - I am really spinning my wheels on this stuff.

Clem C

petefs
04-29-2004, 02:25 PM
This was argued about for a while, and it's been taken care of recently.

I'm not sure if it's bad form to link to it directly, so this is from Justin Watkin's website:

http://www.justin-watkins.com/

And here's a link to the file -- replace the app/Executive.php with this file.

http://www.justin-watkins.com/test/Executive.phps

clem_c_rock
04-29-2004, 04:18 PM
Wow - now let me get this straight - was this really a bug I encountered? I overcame this problem by calling the second method from the first methods responder object. I will try this new executive class.

I appreciate the help.


Clem C

petefs
04-29-2004, 05:30 PM
aye, a bug indeed...your workaround works, of course, but it's a pain in the ass to do it that way : ) Hope the new executive.php straightens things out for you ^_^

clem_c_rock
04-30-2004, 09:18 AM
Worked beautifully! Thanks so much - I've been on the verge of madness trying to figure out this problem.

I will name my firstborn in your honor.

Thanks again.

Clem C

petefs
04-30-2004, 02:29 PM
Name it in Justin Watkin's honor -- I just pointed you to the fix : ) Just glad to see more people using AMFPHP ^_^

clem_c_rock
05-06-2004, 10:12 AM
Mr Watkin rules!

MicahM
06-04-2004, 01:52 PM
This is a dead post, but I have the exact same problem. What I am worried about is this solution being so old... I have AMFPHP 0.9.0b and I don't want to mess things up too much by replacing a file.

Sooo... can anyone tell me if this fix is safe for this version of AMFPHP? Or better yet, what exactly was changed so I can do it by hand...

-Micah

MicahM
06-04-2004, 01:54 PM
Nevermind, I found another solution to the problem here:
http://www.dynamicflash.co.uk/index.php?m=200307#18
Just use an absolute path in your gateway.php file instead of a relative path for services.