The process I am creating needs to send data to a soap service. I cannot proceed with my next action until I get a desirable response.
try {
$return = $soapClient->__soapCall("BulkLoadContacts",array('parameter' => $params));
foreach ($return as $r){
$upload_id = $r;
}
$process_params = array(
'ProcessID' => $upload_id,
);
$return = $soapClient->__soapCall("GetProcessStatus",array('parameter' => $process_params));
var_dump($return);
}
catch(SoapFault $fault){
$status = false;
}
In the above piece of code, I execute the BulkLoadContacts method. I then grab the ProcessID from the response. Once I have that ID, I then make another call to get the status of the my process. The last dumper tells me the response of GetProcessStatus. The dumper looks like:
object(stdClass)#18 (1) {
["WSProcessStatus"]=>
object(stdClass)#19 (6) {
["ProcessID"]=>
int(3313881)
["ListID"]=>
int(268207)
["ProcessName"]=>
string(20) "listrak_tempfile.txt"
["ProcessStartTime"]=>
string(23) "2012-05-16T14:22:50.643"
["ProcessCompleteTime"]=>
string(22) "2012-05-16T14:22:50.84"
["Status"]=>
string(19) "ProcessingCompleted"
}
}
The last item is Status. Only until the method returns with the value of “ProcessingCompleted” do I want to proceed. Any suggestions on how to accomplish this? Would a simple do-while be sufficient?
A do/while should do the trick. But I’d recommend putting a delay in each loop, otherwise you’ll be hammering the Soap server.
Also, you probably want to specify a max number of tries. You don’t want to have your program stuck in an infinite loop.