Forum Moderators: coopster

Message Too Old, No Replies

Asynchronous callback problem with PHP. Difficult :(

How to create an asynchronous

         

coolclu3

8:56 am on Jun 20, 2008 (gmt 0)

10+ Year Member



Hi all,
I have an interseting scenario as follows:

1. I have a server A that provides a webservice (Written in C and using axis2C).
Basically the service, say process_me() takes a string as input, and returns a string.

2. A PHP server B that uses this process_me(). The returned string will be inserted into some database.

Problem is process_me() takes quite a while and server B needs to wait for that. Now, I don't like this.

What I am thinking is:
1. B calls process_me() and contines doing something else. (I'm not even sure if B can leave process_me() and go away)
2. B has some update_db.php utilities that server A , once finished processing, can call to return the string (possibly together with some session id). update_db.php will insert the string to the right DB

Please tell me how to achieve this. Or is tehre some other way to achieve this better? All I want is a nice asynchronous flow

Thanks for reading
Cheers

cameraman

10:51 am on Jun 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you call process_me(), could you pass an address (script) that A can report the results to on B?

coolclu3

11:51 am on Jun 20, 2008 (gmt 0)

10+ Year Member



Yes, I can always modify to have that available. But I guess there might be some issues:

1. Can A report result back to B?
Right now i'm thinking A could do something like this in its axis2c wrapper:
wget ("http://B/update_db.php?data=****");

Or there might be better way the language C can do this.

2. Security
How can update_db.php make sure that this is a request from A ?
Sesssion id? No, probably too complex :(
IP check? Uhm...maybe...

Waiting for your thoughts, cameraman, and yes, thanks!

(I'm not very sober now, sorry if I'm not being clear)