AnsweredAssumed Answered

SOAP based web service calls failing intermittently

Question asked by jb31639 on May 13, 2016
Latest reply on Nov 21, 2017 by mkauffman

Hello

I'm using PHP to access Blackboard's SOAP based web services to get current memberships for an external app to allow staff to bulk unenrol from older courses.

 

It all works fine on our STAGE server but on our live server it regularly fails. I've had this before with other systems and it feels like load/number of connections. I have put a ticket in with Blackboard as we're on managed hosting so I'm not sure if there's some kind of load balancing thing going on.

 

I'm using this to get latest enrolments

GitHub - stedwards/Blackboard-Web-Services-PHP-Library: A php library for connecting to the Blackboard 9 Web Services AP…

 

In the bb.php doPostRequest method there's this code which I've altered a little bit to throw exceptions (see below). The code is regularly failing but not always on:

$fp = @fopen($url, 'rb', false, $ctx);

and

$response = @stream_get_contents($fp);

 

Not always but enough to make me worry! Has anyone got any tips to avoid this type of error? I'd quite like to use the web services but not sure how well it will cope under load? If it was about 1/10 I'd probably live with it and am currently redirecting to a nice error page but it's probably more like 3-5/10 and I suspect it might get worse under load. Can anything be done?

 

 

Sorry, thought I'd try here in case anyone else had workarounds

 

Thanks

Jas

 

bb.php call:

private function doPostRequest($url, $data, $optional_headers = null) {

   $params = array('http' => array(

             'method' => 'POST',

             'content' => $data

           ));

  if ($optional_headers !== null) {

  $params['http']['header'] = $optional_headers;

  }

  $ctx = stream_context_create($params);

  $fp = @fopen($url, 'rb', false, $ctx);

  if (!$fp) {

  throw new Exception("Problem with $url, connecting to Web Service 1 fopen");

  }

  $response = @stream_get_contents($fp);

  if ($response === false) {

 

  throw new Exception("Problem reading data from $url, web service 2 stream_get_contents");

  }

 

  return $response;

  }

Outcomes