Search code examples
phpsoapnusoap

Fire and forget web service/SOAP action


I have the following action registered in my nusoap service:

$server->register(
        'testfunction',
        array('value' => 'xsd:string'),
        array( ),
        'urn:test_services',
        'urn:test_services#testfunction'
);

...and the function itself:

function testfunction($value)
{
    // do something with $value
}

I want the action to be "fire and forget", i.e. whatever calls it doesn't have to hang around for a response. I just passed an empty array for the response argument of $server->register. I thought that might achieve what I was looking for, but that's not been the case (client hangs around for a response).

The WSDL looks like this:

<message name="testfunctionRequest">
    <part name="value" type="xsd:string"/>
</message>
<message name="testfunctionResponse"/>

Is there a way to achieve such functionality with nusoap? I'm not sure if "fire and forget" is the right terminology to be using, so I've had a bit of trouble searching for possible answers to this!


Solution

  • You need to detach current execution from web server process and close connection: using pcntl_fork() or running PHP script in background - Asynchronous shell exec in PHP

    Another option is to add information about request to some queue. This queue may be MySQL (or other DBMS) table or some kind of storage like MemcacheQ, RabbitMQ etc. And, then, retrieve information from queue by another independent script and process it.