I am calling the 3 Waitset SOAP functions in sequence within a php function.
Basically, I am trying to wait for changes on an account - and then to parse through the changes to see if any relevant ones have occurred.
But when I call the WaitSetRequest with a 30 second timeout - I am getting back responses in a very unpredictable manner. Sometimes too fast - other times too slow. No consistency.
This is just an extract from the code where I built the calls to the WaitSet functions and parse the responses.
It does not include the blocks of code that actually make the curl calls, and parse the XML, etc. but it should be enough for you to understand how I am trying to use the API.
Code:
$soap = '<CreateWaitSetRequest defTypes="all" xmlns="urn:zimbraMail" >
<add><a id="'.$this->_zimbraId.'" /></add>
</CreateWaitSetRequest>';
debugLog( 'CreateWaitSetRequest ['.$soap.']' );
$response = $this->SoapRequest($soap);
if($response) {
debugLog( 'CreateWaitSetResponse: ' . print_r( $response, true ) );
$array = $this->MakeXMLTree($response);
//debugLog( 'Response '.print_r( $array, true ) );
unset($response);
$this->_pingtokenOne = $array['soap:Envelope'][0]['soap:Header'][0]['context'][0]['change'][0]['token'];
debugLog( 'Token ['.$this->_pingtokenOne.']' );
$this->_waitSetId = $array['soap:Envelope'][0]['soap:Body'][0]['CreateWaitSetResponse'][0]['waitSet'];
$this->_highestSeqKnown = $array['soap:Envelope'][0]['soap:Body'][0]['CreateWaitSetResponse'][0]['seq'];
debugLog( 'WaitSetResponse: SEQ [' .$this->_highestSeqKnown. ']' );
}
debugLog( "Calling WaitSetRequest for 30 seconds" );
$soap = '<WaitSetRequest waitSet="'.$this->_waitSetId.'" defTypes="all" seq="'.$this->_highestSeqKnown.'" block="1" timeout="'.$timeout.'" xmlns="urn:zimbraMail" >
<update>
<a id="'.$this->_zimbraId.'" token="'.$this->_pingtokenOne.'" />
</update>
</WaitSetRequest>';
debugLog( 'WaitSetRequest ['.$soap.']' );
$response = $this->SoapRequest($soap);
if($response) {
debugLog( 'WaitSetResponse ['.$this->_pingtokenOne.']: ' . print_r( $response, true ) );
$array = $this->MakeXMLTree($response);
//debugLog( 'Array '. print_r( $array, true ) );
unset($response);
$this->_highestSeqKnown = $array['soap:Envelope'][0]['soap:Body'][0]['WaitSetResponse'][0]['seq'];
debugLog( 'WaitSetResponse: SEQ [' .$this->_highestSeqKnown. ']' );
}
$soap = '<DestroyWaitSetRequest waitSet="'.$this->_waitSetId.'" xmlns="urn:zimbraMail" />';
debugLog( 'DestroyWaitSetRequest ['.$soap.']' );
$response = $this->SoapRequest($soap);
if($response) {
debugLog( 'DestroyWaitSetResponse ['.$this->_pingtokenOne.']: ' . print_r( $response, true ) );
$array = $this->MakeXMLTree($response);
//debugLog( 'Array '. print_r( $array, true ) );
unset($response);
}