How do I do this? Is it a web service?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Klaws_wolverine
Forum Commoner
Posts: 32
Joined: Mon Sep 29, 2003 10:11 am

How do I do this? Is it a web service?

Post by Klaws_wolverine »

Hi all,

I have an online form, this form must be sent to another server that will parse it. If that server is down, all form data should be queued, also this way data will only be sent from our site's IP address, to prevent DDos attacks.

Anyhow, how do I do this queuing thing? Should I create a SOAP envelope, is a web service needed?

I would apreciate any help anyone can provide.

Thanks
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

not sure if queueing is possible

unless you do somethng to the effect

if
//connection possible
send
else
//connection not possible
store in MySQL

try googling i have no idea, btw there are several software that can do this
http://www.hotscripts.com/PHP/Scripts_a ... more4.html
Klaws_wolverine
Forum Commoner
Posts: 32
Joined: Mon Sep 29, 2003 10:11 am

not a mailing list

Post by Klaws_wolverine »

Hi,

Actually I cannot use those scripts at the link, because it's form data that will be sent, not an smtp email.

I need to know how to do this with a web service, and from what i've heard, it will be queued and web services takes care of that for you.

Thanks
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: not a mailing list

Post by Weirdan »

Klaws_wolverine wrote: I need to know how to do this with a web service, and from what i've heard, it will be queued and web services takes care of that for you.
If you decide to implement queue by yourself, I'd suggest the following `hand-made` design:
1. script, say accept.php, accepts the data from the customer and place it into queue (mysql db or file or something).
2. another script, either the standalone daemon or cron job retrieves the data from queue and posts it to remote processing server (You can do it using [php_man]curl[/php_man] extension).
Klaws_wolverine
Forum Commoner
Posts: 32
Joined: Mon Sep 29, 2003 10:11 am

Yes, that's it

Post by Klaws_wolverine »

Hi Weirdan,

While it is in the queue line, does it have to go into mysql or in a file, can't it be in-memory?

Regarding your accept.php and ur curl function, would you be so kind as to provide some snippets of code? And I don't know curl at all, what's the learning curve?


I would apreciate any help anyone can give me. I was initially think of doing this with NuSOAP.

Thanks
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Yes, that's it

Post by Weirdan »

Klaws_wolverine wrote:While it is in the queue line, does it have to go into mysql or in a file, can't it be in-memory?
It can't, I guess. What if the server which hosts accept.php is crashed before it has submitted the data to processing server?
Klaws_wolverine wrote: Regarding your accept.php and ur curl function, would you be so kind as to provide some snippets of code? And I don't know curl at all, what's the learning curve?
Curl: first, read the manual, this extension has pretty straightforward syntax. It's as simple as

Code: Select all

$ch=curl_init("http://remote.server.com/remote/page.php");
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch,CURLOPT_POST,true);
 curl_setopt($ch,CURLOPT_POSTFIELDS,array("first_field"=>"something","second_one"=>"something_else"));
 $result=curl_exec($ch);
 // now $result variable holds the remote server response
accept.php:
Simple form processing page which stores the data into db.

Writing a daemon can be a bit tricky, I'd suggest not to go this way if you haven't ever wrote one ;). Use cron instead. Here is a tutorial.
Post Reply